Acrobat User Community Forums

You are not logged in.     Log in to your AUC account.     Don't have an account? Sign up today

#1 2007-11-02 12:23:37

gadgetman
Member
Registered: 2007-11-02
Posts: 8

If, else script?

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

Offline

 

#2 2007-11-03 16:54:56

pddesigner
Member

Registered: 2007-04-24
Posts: 64

Re: If, else script?

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.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson

AcrobatUsers.com  >>  User Groups • News • Events • Articles • Blogs • How To • Resources • Member Log in