Copy link to clipboard
Copied
Working on a Mac with El Capital using Acrobat Pro DC 2015.016.20045
I am creating a 6-page form with hundreds of fields. I am trying to figure out how to subtract the sum of a total of 42 fields from a sum of total of 98 fields.
I have 2 subtotal boxes with the sum of all of the 42 (called B) fields and 98 (called A) fields. I tried to do a simple calculation in the Properties Calculate tab:
A - B.
It didn't work.
So I tried ignoring the subtotal boxes and making the calculations directly, using all of the 98 fields minus all the 42 fields:
(field1+field2+field3+...+field98) - (field101+field102+field103+...+field42)
All of the fields were listed (no ... in the equation). I used the parentheses around each set of numbers. Still didn't work. So, what am I doing wrong?
"Didn't work" meant that the field remained empty.
I was able to get some help with my javaScript:
// Get first field value
var v1 = getField(“Text1”).value;
// Get second field value
var v2 = getField(“Text2”).value;
// Set this field value equal to the difference
event.value = v1 - v2;
This script worked when I substituted my field names for Text1 and Text2.
Thanks to you both for your help.
Copy link to clipboard
Copied
Both options should have worked. What does "didn't work" mean, exactly? Did you get no results at all? The wrong results? Were there any error messages in the JS Console?
Generally speaking I would recommend that you use a custom script instead of the Simple Field Notation option for such complex calculations. It provides much greater control and better error messages in case something goes wrong.
Copy link to clipboard
Copied
"Didn't work" meant that the field remained empty.
I was able to get some help with my javaScript:
// Get first field value
var v1 = getField(“Text1”).value;
// Get second field value
var v2 = getField(“Text2”).value;
// Set this field value equal to the difference
event.value = v1 - v2;
This script worked when I substituted my field names for Text1 and Text2.
Thanks to you both for your help.
Copy link to clipboard
Copied
Did you open the Acrobat JavaScript console to see if there are any messages?
Did you check the field calculation order?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now