Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Acrobat DC forms: subtraction

Guest
Jun 22, 2016 Jun 22, 2016

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?

TOPICS
Acrobat SDK and JavaScript
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Jun 22, 2016 Jun 22, 2016

"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.

Translate
Community Expert ,
Jun 22, 2016 Jun 22, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 22, 2016 Jun 22, 2016
LATEST

"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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 22, 2016 Jun 22, 2016

Did you open the Acrobat JavaScript console to see if there are any messages?

Did you check the field calculation order?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines