Highlighted

## How to subtract in a calculation in Acrobat Pro 9

Community Beginner ,
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

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

## How to subtract in a calculation in Acrobat Pro 9

Community Beginner ,
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

30.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
Sep 08, 2008 1
8 Replies 8
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
Sep 08, 2008 4
New Here ,
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
Nov 06, 2020 0
LATEST
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
Nov 06, 2020 0
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
Sep 08, 2008 2
Community Beginner ,
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
Sep 08, 2008 0
Community Beginner ,
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
Sep 08, 2008 0
New Here ,
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
Mar 18, 2009 0
Resources