These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

percentage calculation

jpcutler85
Registered: Nov 16 2009
Posts: 38

I have a total value which is a sum of a series of prices. I want to calculate 40% of that total price value and add it to a separate field.

The total price value is variable depending on quantity's of items ordered.

How would I go about doing this as a custom script? Looking around the forum I see similar scripts for percentage calculations but not quite what I want.

Thanks!

My Product Information:
Acrobat Pro 9.3.1, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Say that the name of your sum field is "Sum", and the name of the field you want to add to 40% of the sum is "OtherField". Then, in the field where the calculation result will be placed add a calculation in Simplified Notation.

0.4*Sum + OtherField

That all.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

jpcutler85
Registered: Nov 16 2009
Posts: 38
Awesome, works great. Thankyou
jpcutler85
Registered: Nov 16 2009
Posts: 38
What if I want to make the 40% a variable field?

So I would have total price value. Then x% of total price value =

The x% value will be a separate field.
try67
Expert
Registered: Oct 30 2008
Posts: 2399
If that field is called Percentage, then you use:

Percentage * Sum + OtherField

Make sure the value of the field is 0.4 (or 40%), not 40.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com