These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

using a check box to add a value to a Decimal Field

VinZe75
Registered: Oct 14 2008
Posts: 4

I’m new Adobe user with some collage programming background 5 years ago, I’m having trouble with this syntax.

if checkbox1 value = 1, then add the value of DecimalField1 to DecimalField2, Else, add the value of DecimalField1 to DecimalField3

DecimalField1 is a constant value.

DecimalField2 and 3 would be a Sum of several other DecimalFields.

My Product Information:
Acrobat Pro 8.0, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Do you currently have DecimalField2 and 3 set up as calculated fields? If so, did you use JavaScript or something else? If JavaScript, can you show us the code you used?

In which field do you want to place the result of the checkbox-dependent calculation?

To clarify, are you using Acrobat or LiveCycle Designer to create the form?

George
VinZe75
Registered: Oct 14 2008
Posts: 4
I am using Acrobat to build this form.
DecimalField2 and 3 are not set up to calculate.

The form is designed to sum up business travel expenses.

DecimalField1 is labeled “fuel for rental car” with a dollar value manually inputted. Next to DecimalField1 is checkbox1. If checkbox1 is checked, then add the value of DecivalField1 to DecimalField2 “personal expense”. If it is not check, then add that value to DecimalField3 “business credit card”.

DecimalField2 and 3 would receive running sums based on the state of several checkboxes in the form.
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Then the key is to set up the scripts that calculate the values for DecimalField2 and DecimalField3 correctly. You haven't provided enough information for us to suggest specific code, but the general approach would be to have the code check the value of the check box(es), and if checked, decide which sum should get the amount that's in the DecimalField1 (etc.) added to it.

The script would get triggered by the Mouse Up event of each check box, and the script would check the values of all of the check boxes, get the corresponding amounts from the text fields, perform the calculation based on the state of the check boxes, and set the values of the fields that hold the sums.

The other approach would be to set up DecimalField2 and 3 as calculated fields, with similar calculations.

George