If Statement

I am converting an excel form into a pdf form and am trying to duplicate an 'if' statement used in the excel form. the initial value im using comes from a text field called 'aa', I want the calculated value to be placed into a text fields called 'bb'.

i have created both text fields, opened up the properties for text field 'bb' and in the calculate tab selected 'custom calculation script'. This is the code:

var z = this.getField("aa").value;

if (z<=0)
{
bb.value = z*0.0575;
}
else
if (z>0)
{
bb.value = z*0.0475;
}

i cant find anything wrong with the code, but for some reason the final value (bb.value) doesnt get displayed in the 'bb' text field on the form. It just remains blank. Any help would be appreciated!

Also, i am using Adobe Acrobat X Standard


Daniel Blickling


3 Answers

Replace all instances of "bb.value" with "event.value".


Gilad D (try67)   

Where has be "bb" object been established?

If you are trying to access the field in which an action is located, one usually uses the "event" object.

Also if a value is not less than or equal to zero it is then greater than zero.

You can use the following script for the custom calculation script for the field "bb":

var z = this.getField("aa").value;

if (z <= 0) {
event.value = z * 0.0575;
} else {
event.value = z * 0.0475;
}

If you open the JavaScript console you should see an error about "bb" not being defined.


George Kaiser   

var z = this.getField("aa")

if (z .value<=0)
{
bb.value = z .value*0.0575;
}
else
if (z .value>0)
{
bb.value = z .value*0.0475;
}


R Rios   


Please specify a reason: