auto update a field based on two other fields values

auto update a field based on two other fields values

Hi,

I would like to do the following:

Have a Label with a number say 10

Have a text box with user entry numeric only 0-10

Have another text box with user entry numeric only which equals the label value minus the text box value

i.e. 10 - 5 = 5

Seems a pretty straightforward feature but I can't figure out how to do it?

Any help would be appreciated.

Thanks

Mat

 

  • 06 September 2018
  • SOTI Snap
  • 3 Answers
  • 0 Upvote
  • 1 Follower
  • 644 Views
    • 3 Answers
    • 0 Upvote
    • 1 Follower

3 Answers

Order By:   Standard | Newest | Votes
SMod@Soti | posted this 06 September 2018

 Hi Mat,

 

This can be accomplished using JavaScript.

For example,

Add the label with the fixed numeric value (say 10)

Set the ID of the first textbox to 'v1' (you can use any name)

Add the second textbox and set its ID to 'v2'

Now for the first textbox v1, go to events and from the drop down for events, select OnBlur and 'Run JavaScript' as the action.

Open the Script Editor and paste the following code:

document.getElementById("v2").value = 10 - document.getElementById("v1").value;

 

The logic behind this is as follows:

The user enters a value in textbox 1 (v1) and when they leave the textbox 1 (blur) the javascript code takes the value in textbox 1 and subtracts it from 10 and assigns it to textbox 2 (v2).

Feel free to change the fixed variable from 10 to any other number.

 

Please let me know if you have any questions.

 

Thanks

Technical Support | SOTI Inc. |1.905.624.9828 | support@soti.net | soti.net |

 

  • 0
  • 0
Mat Lawrence | posted this 07 September 2018

Worked perfectly! Thank you so much. Is there a reference guide online for the Javascript?

Regards

Mat

 

  • 0
  • 0
SMod@Soti | posted this 10 September 2018

There is no official reference guide for JavaScript commands but all the general statements and commands should work as expected in SOTI Snap.

 

Please let me know if any further information is required.

Technical Support | SOTI Inc. |1.905.624.9828 | support@soti.net | soti.net |

 

  • 0
  • 0
Give us your feedback
Give us your feedback
Feedback