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

Null if zero

tdunn
Registered: Aug 3 2007
Posts: 14

I am making a form fillable and have a field that calculates the sum of other fields. It defaults to $0.00 when no information is entered. I have clients that would rather print the form and fill it out manually and I don't want that $0.00 to show. I realize I need to use a validation script to change to null if 0.00 but I am a java script dummy. Could you give me the exact formula 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 is created on a "total" field. If quantity is not equal to zero (in other words some data is in the field) then the quantity is multiplied by the price (a fixed vailue). If quantitly is equal to 0 (else...) then the last line of code removes the default zero.

var f = this.getField("quantity");
var g = this.getField("price");

if (f.value != 0)
event.value = f.value * g.value
else
event.value =""

Hope this helps.

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

tdunn
Registered: Aug 3 2007
Posts: 14
None of that makes sense to me. I just don't want the zero's to show! I don't need it to do any fancy stuff, I just want the field to be blank if no data is entered anywhere on the form. I don't understand why this is so hard. I have asked this same question about six different ways and I have gotten six different answers - none of which work. Please, oh please just make the zero's go away!
cwb2
Registered: Aug 22 2007
Posts: 1
I see where you're coming from. I'm looking into doing the same simple task and having trouble. In my case I have three fields; rate, hours and total. On the total filed I have a simple (rate * hours) script. It defaults to a $0.00 value when nothing is entered into rate and hours. How do you make this go away? If there is no value in rate or hours I just want the total to be "blank". Can this be done? Thanks.
tedpadova
ExpertTeam
Registered: Dec 31 2005
Posts: 848
Basically, you use the script I suggested in the previous post. Just open the field Properties dialog box, click the Calculate button and add a JavaScript using the same code as above but substitute my Quantity for your rate and my Item for your hours.

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.