• Global community
• Language:
• Deutsch
• English
• EspaĆ±ol
• FranĆ§ais
• PortuguĆŖs
• ę„ę¬čŖć³ćć„ććć£
Dedicated community for Japanese speakers
• ķźµ­ ģ»¤ė®¤ėķ°
Dedicated community for Korean speakers
• Re: How to subtract in a calculation in Acrobat Pr...

# How to subtract in a calculation in Acrobat Pro 9

Community Beginner ,
Sep 08, 2008 Sep 08, 2008

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

39.6K

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
9 Replies 9
LEGEND ,
Sep 08, 2008 Sep 08, 2008

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

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Nov 06, 2020 Nov 06, 2020

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

Likes

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

Copied

Use this:

event.value = v1 - v2;

Likes

Report

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

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

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Sep 15, 2022 Sep 15, 2022

Copied

LATEST

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

Likes

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

Copied

your the best, gonna try it out!

Likes

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

Copied

works!

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Mar 18, 2009 Mar 18, 2009

Copied

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

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Mar 20, 2009 Mar 20, 2009

Copied

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

Likes

Report

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