Forum Post: RE: How can we use Dynamic Calculation field

  • Thread starter Thread starter Godfrey Sorita
  • Start date Start date
Status
Not open for further replies.
G

Godfrey Sorita

Guest
Hi Sudhakar, You can use Rollbase client-side APIs to compute the total dynamically. For example, you have 'num1', 'num2', 'num3' and 'sumField' integer fields on your form. To compute the sum, paste the code below on a script component on your form's page editor: script function computeSum() { var num1 = rbf_getFieldValue('num1'), num2 = rbf_getFieldValue('num2'), num3 = rbf_getFieldValue('num3'), sum = parseInt(num1) + parseInt(num2) + parseInt(num3); rbf_setFieldValue('sumField', sum); } /script Then, add the computeSum() function to the onchange events of 'num1', 'num2' and 'num3' fields. This will compute for the total when any of the three fields are changed. Please see Chapter 7 of Rollbase in Action . Regards, Godfrey

Continue reading...
 
Status
Not open for further replies.
Back
Top