Highlighted

Apply Script to multiple fields

Avatar

Guest

22-07-2008

I have a form with multiple fields that will contribute to a total. Is there a way to have script apply to multiple fields that will auto update the totals, instead of scripting a separate exit event for each field.



Thank you

Replies

Highlighted

Avatar

Guest

22-07-2008

Create a Script Object. In that object, you can have a function like this:

function addMyFields() // add values in the fields

{

var number1 = field1.rawValue;

var number2 = field2.rawValue; // and so on



var sumOp = number1 + number2; // + number3 + .... and so on



totalField.rawValue = sumOp; // display sum in total field

}



Paste the following code in the exit event of each field:

ScriptObjectName.addMyFields();



Let me know if it works for you.
Highlighted

pguerett

22-07-2008

Or put your code on the Calculate event and as each field is changed the Total calculate event wil fire because there is a dependency between each field mentioned in the calc.