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

Total newbie - help with conditional calculation script for form field

Stevo9
Registered: Apr 9 2008
Posts: 4
Answered

Ok,

I understand how to use something like Excel for performing conditional calculations, but my first foray into this Java stuff is like Greek to me.

Here's the script I inserted into a field calculation.

var f = getField("csd");
if (f < 0.5){event.value = 0}
else {event.value = ((f.value - 1) * 40) + (45)};

When I type the value 1 (or more) into the "csd" field, the calculation is correct.

When I type 0 into the "csd" field, the event value comes out 5, not 0 as I would like.

I know this is extremely basic, but I gave up trying to understand the Java script info since it "hurts my head".

My Product Information:
Acrobat Standard 5.x or older, Windows
Stevo9
Registered: Apr 9 2008
Posts: 4
C'mon guys! I REALLY need some quick help here. I've got to finish my form and I am stuck.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You have an error in your script. The "if" is refering to the field, and not the field's value. It should be:

var f = getField("csd");
if (f.[b]value[/b] < 0.5)
{
event.value = 0
}
else
{
event.value = ((f.value - 1) * 40) + (45)
};

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

Stevo9
Registered: Apr 9 2008
Posts: 4
Thanks for your very much appreciated assistance. Now that you showed me the error, it is embarrassingly obvious.

Thanks again!