- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2016 02:54 PM
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!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2016 12:42 PM
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);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2016 02:58 PM
It will be a client script. In your html call a change event and use the function that is defined in the client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2016 11:14 AM
Hi Abhinay, thanks for your advice. I'm not too familiar with writing these scripts so please excuse the possible silly questions. In my UI Page, I've written the following script in the Client Script section:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var a = g_form.getValue('total_a');
var b = g_form.getValue('total_b');
var c = g_form.getValue('total_c');
var d = g_form.getValue('total_d');
var e = g_form.getValue('total_e');
var f = g_form.getValue('total_f');
var g = g_form.getValue('total_g');
var h = parseInt(a) + parseInt(b) + parseInt(c) + parseInt(d) + parseInt(e) + parseInt(f) + parseInt(g) + parseInt(h);
g_form.setValue('grand_total',h);
}
What I'm hoping is that as a user enters in total_a, total_b, etc, that grand_total dynamically totals these up. Is my code above correct? I can't seem to get the grand_total line to change as different values are entered into A through G.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2016 11:24 AM
Hi David,
If you're using UI page, you need to add the onchange in your <input> tag and call the function sum() written in your client script.
See below:
<input type="number" id="grand_total" onchange="sum();"></input>
Client Script:
function sum()
{
document.getElementById("grand_total").value = parseInt(document.getElementById("total_a").value) + parseInt(document.getElementById("total_b").value) + ....
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2016 11:35 AM
Can you post the html section of your UI page.