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

If, else script?

gadgetman
Registered: Nov 2 2007
Posts: 14

Is there a way to have a form field set to contain a certain value IF the contents of another field contains a certain value. For instance... if a field titled NAME contains "Smith", then the field titled NUMBER would contain "5". I assume its gotta be done w/ a script, and if so, can someone help me out w/ it by letting me know what the script should be and which field to enter it in?? If not, is there another way to do it?
 
I'm using a Mac with Acrobat 8 professional

My Product Information:
Acrobat Pro 8, Macintosh
pddesigner
Registered: Jul 9 2006
Posts: 858
Create a Text field named "results"
Click the Calculate property tab and paste this Custom calculation script.

var c = this.getField("name.0")

{
if
(c.value == "Smith")
(event.value = 5);
else

if
(c.value == "Thomas")
(event.value = 8);
else

if
(c.value == "Jones")
(event.value = 9);
else

if
(c.value == "Peterson")
(event.value = 10);
else

if
(c.value == "Stewart")
(event.value = 4);
else

if
(c.value == "Mason")
(event.value = 1);
else

if
(c.value == "Lawson")
(event.value = 7);
else

if
(c.value == "Edwards")
(event.value = 3);
else

if
(c.value == "Nash")
(event.value = 4);
else

if
(c.value == "Wilson")
(event.value = 2);
else

if
(c.value == "Green")
(event.value = 6);
}

Create a combo Box with the following properties:

Name it: name.0
Click the Options tab and list all the names listed for the c.value in the Text field.
Check the box titled: Commit selection value immediately.

Save and test by clicking an item in the combo box and observe the results.

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.