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

If Then Statement Question

raybsox
Registered: Jan 16 2008
Posts: 3
Answered

I want to write an if, then statement where if the value of my text field I titled "Test" is 1 or greater, than the value "1" will be placed in the text field I am calculating. If the value of "Test" is 0 or "", then the value "0" will be placed in the text field I am calculating.

From other searches I have done, I have come up with the following script:

var f = this.getField("Test").value;
if (f.value >= 1)
event.value = 1;
else
event.value = 0;

Both text fields are formated to be numbers. I am sure that I am missing something simple! Please help!

My Product Information:
Acrobat Pro 7.0, Macintosh
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Within Acrobat JavaScript, you are dealing with objects which have properites or methods associated with them. You can create a variable that is either the object, holds the value of a property for the object, or the result from a method.

Since you have defined "f" as having the value property of the "Test" field object, you can not get the value of the value.

var f = this.getField("Test").value;
if (f >= 1)
event.value = 1;
else
event.value = 0;or

if (this.getField("Test").value >= 1)
event.value = 1;
else
event.value = 0;

George Kaiser

raybsox
Registered: Jan 16 2008
Posts: 3
Thank you so much! This works perfectly now.