Apply Script to multiple fields

Avatar

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

Avatar

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.

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile
pguerett
Level 10

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.