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

HELP - Java Script Calculation Not Working

nalleyl
Registered: Oct 20 2008
Posts: 4
Answered

I need to find the net value of three text boxes. I have the following Java Script but it isn't working. Any ideas what I am doing wrong?

var a = this.getField("Void Amount").value; // variable for the estimated value
var b = this.getField("Parts Total").value; // variable for the actual value
var c = this.getField("Labor Total").value; // variable for the actual value
this.getField("Net Void").value =(b+c)-a; // variable for the actual value

Ex: I need to find the "Net Void" amount total - Say the Void Amount is $500 from that I need to subtract the sum of "Parts Total" $125 and "Labor Total" $100. The Net Void would be $275 but I can not get the java script to calculate this.

These values are all right next to each other on the form ie: Void Amount, Parts Total, Labor Total, Net Void

Any help will be GREATLY APPRECIATED.

Thanks and have a good day!

LKN

Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi nalleyl,

Read this article at JavaScript Corner on calculation scripting-
http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/form_calculations/

In that article it explains that you need to assign a value to the event.value variable, which is missing in your script.

Also, when scripts are not working you should use the Console Window to see what errors if any are reported. If you don't know how to use the Console Window you can read all about that at-
http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/javascript_console/


Hope this helps,

Dimitri
www.pdfscripting.com
www.windjack.com
nalleyl
Registered: Oct 20 2008
Posts: 4
Thanks so much for the helpful informtion. Instead of using the "Custom Calculation Script", I used the "Simplified Field Notation" with the following:
VoidAmtRow1_A - (PartsRow1_B + LaborRow1_C)
I achieved the results that I was looking for. Thanks again your help is really appreciated. :)