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

Calculation

M_Torrick
Registered: Sep 12 2007
Posts: 6

I am new to creating calculations using Acrobat. I have a form where a user can enter up to 4 pay check amounts. I can get Acrobat to calculate the sum of those 4 fields. Here is where I am lost. I would also like to calculate the average of the sum based on the number of pay checks entered. From that, I would like to calculate an average pay amount based on whether the employee is paid weekly (x 4.333), bi-weekly (x 2.167), or semi-monthly (x 2). Any help will be greatly appreciated. Thanks…Mike.
 
[link=mailto:Michael [dot] Torrick [at] dfa [dot] state [dot] ny [dot] us]Michael [dot] Torrick [at] dfa [dot] state [dot] ny [dot] us[/link]

My Product Information:
Acrobat Pro 7.0.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Assuming you are using AcroForms (Not LiveCycle Designer) then please Read this Article on calculations:

[url=http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/form_calculations/]http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/form_calculations/[/url]

And this on on dates calculations:

[url=http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/date_time_part1/]http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/date_time_part1/[/url]


To calculate your average you'll need to detect empty fields. Empty Fields typically have a null value, but this is not always true. It might just be an empty string or even white space. You can use this line of code to do empty field detection. The field is named "input1".
var myFldVal = this.getField("input1").value;if( myFldVal && !(/^\s*$/.test(myFldVal)) ){// Not Empty... your code ...}

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

M_Torrick
Registered: Sep 12 2007
Posts: 6
I guess I should have prefaced my question with the fact that I know nothing about JavaScript so I am not sure how to proceed.

Thank you in advance for any more help you may be able to provide.