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

How to subtract in a calculation in Acrobat Pro 9

Community Beginner ,
Sep 08, 2008 Sep 08, 2008

Copy link to clipboard

Copied

I'm building a pdf with some calculations. I can do a 'sum, product,average,minimum,maximum'. But how do i subtract 2 fields?

Views

48.8K

Translate

Translate

Report

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 ,
Sep 08, 2008 Sep 08, 2008

Copy link to clipboard

Copied

You will need to use JavaScript in a field's custom calculation script. For example:

// 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;

You would replace "Text1" and "Text2" with the names of the fields you've set up.

George

Votes

Translate

Translate

Report

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
Participant ,
Nov 06, 2020 Nov 06, 2020

Copy link to clipboard

Copied

I guess I'm missing something. I can't get this to work. Here is the script that I am using.

v1 = getField("Subtotal").value;
v2 = getField("TotalDiscount").value;
TotalDue.value = v1 - v2;

 

Any help would be appreciated.

 

Jack

 

Votes

Translate

Translate

Report

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
Community Expert ,
Nov 06, 2020 Nov 06, 2020

Copy link to clipboard

Copied

Use this:

event.value = v1 - v2;

Votes

Translate

Translate

Report

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
Explorer ,
Dec 13, 2023 Dec 13, 2023

Copy link to clipboard

Copied

LATEST

I used George's suggestions with Bernd's alteration, and it worked great for me. Thanks!

Votes

Translate

Translate

Report

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 ,
Sep 08, 2008 Sep 08, 2008

Copy link to clipboard

Copied

I should not have said you *need* to use JavaScript, because you can also use the "simplified field notation" option, but as you come to do more than the simplest of calculations, JavaScript is what you'll need.

If you want to use the simplified field notation option, you'd enter:

Text1 - Text2


but you'd replace Text1 and Text2 above with the names of your fields.

George

Votes

Translate

Translate

Report

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
New Here ,
Sep 15, 2022 Sep 15, 2022

Copy link to clipboard

Copied

I was unable to subtract using the guidance you provided. Do I need to add an equal sign or something?

Votes

Translate

Translate

Report

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
Community Beginner ,
Sep 08, 2008 Sep 08, 2008

Copy link to clipboard

Copied

your the best, gonna try it out!

Votes

Translate

Translate

Report

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
Community Beginner ,
Sep 08, 2008 Sep 08, 2008

Copy link to clipboard

Copied

works!

Votes

Translate

Translate

Report

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
New Here ,
Mar 18, 2009 Mar 18, 2009

Copy link to clipboard

Copied

George - thank you so much! I didn't ask the question, but I certainly benefited from your assistance. Thanks so much! -dave

Votes

Translate

Translate

Report

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
New Here ,
Mar 20, 2009 Mar 20, 2009

Copy link to clipboard

Copied

How would you write this if you were wanting to subtract dates? I'm using Acrobat 9 as well. Thank you!

Votes

Translate

Translate

Report

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