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

JavaScript for Calculated Text Field

aimer5
Registered: Jan 9 2008
Posts: 4

I am making a form fillable and have a field that calculates the sum of other fields. It defaults to 0.0 when no information is entered. I have clients that would also like to print the form and fill it out manually, and I don't want that 0.0 to show. I realize I need to use a validation script to change to null if 0.0, but I am a JavaScript dummy. Could you give me the script to get this to work?

My Product Information:
Acrobat Pro 7.0.7, Windows
tedpadova
ExpertTeam
Registered: Dec 31 2005
Posts: 848
Here's a script that looks at one field and if the field contents are zero, the event.value of the field containing the script is a null value (represented as: ""):

var f = this.getField("item.0");
var g = this.getField("price.0");
if (f.value !=0)
event.value = f.value * g.value;
else
event.value ="";

ted

The author of numerous books on Acrobat, Photoshop, Illustrator and the Adobe Creative Suite, and an international speaker on Adobe Acrobat, Ted Padova is a well-known PDF guru.