The Zurich release has arrived! Interested in new features and functionalities? Click here for more

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, one more follow up question.   Can I have multiple onchange functions on a UI page or can there only be one?


Abhinay Erra
Giga Sage

You mean multiple onChange events for a single html element?


I mean multiple onChange events for the same UI Page, but on different elements.   For instance I have the sum() above, can I have another that subtracts fields and another that multiplies fields, etc.


Abhinay Erra
Giga Sage

Yes you can. Create an onChange events to those elements and define the functions in the client script.


Hmm, so I created a second onchange event called deduct_3() (which I'm pretty sure the code is wrong), but it seems to render the sum() function unusable :



function sum(){


$('H').value= parseFloat($('A').value)+parseFloat($('B').value)+ parseFloat($('C').value)+parseFloat($('D').value)+ parseFloat($('E').value)+parseFloat($('F').value)+ parseFloat($('G').value);


}







function deduct_3(){


  var c = parseFloat($('deductions_adjustments_1').value) - parseFloat($('deductions_adjustments_2').value);


  if (parseFloat(c) <= 0) {


  $('deductions_adjustments_3').value = 0;


  }


  else {


  $('deductions_adjustments_3').value =c;


  }


  }



With the deduct_3() function in there, the function sum() stops working, any thoughts?



Thanks!