Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

UI Page dynamically calculated fields

yundlu316
Kilo Guru

I've created a form using a UI Page and would like some of the fields to dynamically change depending on what is entered in other fields.   For example if a user fills out field A with $100,000 and field B with $25,000, is it possible for field C to dynamically change to $125,000 (A+B) without submitting or reloading the page?   Would that be a client or processing script?

Thanks!

1 ACCEPTED SOLUTION

You do not need onChange client script declaration. Remove everything from the client script section and just copy this


function sum(){


  $('H').value=parseFloat($('D').value)+parseFloat($('G').value);


}


View solution in original post

28 REPLIES 28

Hey Abhinay,



Wow that worked, but can you explain to me why sum() can be in the HTML section, but deduct_3() has to be moved down to the Client Script section?


Abhinay Erra
Giga Sage

Both can be in either HTML or client script section. I believe you are missing the the script closing tag in the HTML </script>


Well, the </script> tag is below my screenshot, unless each function needs to be contained within their own <script></script>, but I don't think that's true.


Abhinay Erra
Giga Sage

Yeah you can enclose all the functions inside a single script tag. But I usually prefer to write them in the client script section.