[an error occurred while processing this directive]

Community Publishing

Last Updated:
User Level:
Acrobat 8.0LiveCycle ES 8.0

Need more tips and tutorials?

LiveCycle Designer ES - JavaScript Variables

Q: I need to populate several form fields with variables. How would I do that?


A: Step-by-step instructions:

1.Open LiveCycle Designer and create a blank form.

2. Add as many text fields as you need. Be sure to follow the proper naming convention and make a note of their names.

hierarchy view

3. Add variables and values

 variable image

My example:

name1 = George Washington

address = 1600 Pensylvania Ave NW

and so on.


4. Add two check boxes (checkBoxNo and CheckBoxYes) and a text box (Question). Use the text box to type in your question. My example text box named Question: Is this the correct name?

5. Set the text properties for the check boxes to Yes and No respectively.

6. Set the presence properties for the check boxes and the question field to invisible.

7. Add a button (named ButtonFill)

8. Make sure your script editor is open. (Read the Help topic to learn how to open the Script Editor)

9. Select the button and choose the click event for the button. The language should be set to JavaScript and Run At Client

10. Add your JavaScript code and click the green Check Script Syntax button. If you see a highlighted line or lines of code, you did not properly set up your variables or the script for the button click has an error.

My example:

TextFieldName.rawValue = name1.value;

TextFieldAddress1.rawValue = address.value;

TextFieldAddress2.rawValue = address2.value;

TextFieldCity.rawValue = city.value;

TextFieldState.rawValue = state.value;

TextFieldZipCode.rawValue = zip.value;

Question.presence = "visible";

CheckBoxNo.presence = "visible";

CheckBoxYes.presence = "visible";

11.  Click File, Form Properties, and click the default tab. Make sure run version is set for 7.0.5 or later, Default Language is JavaScript, Run at Client and Server is Dynamic XML Form.

12. Click the Preview tab to make sure Preview Type is Interactive Form and Preview as is Dynamic XML Form. Click OK to close this dialog.

13. Save and close. Click the Preview PDF tab

If all goes well you should be able to click the button and see all of your text fields auto filled in.

 Now we need to setup the check boxes and question field.

Note: In all cases with the Script Editor you must always check your scripts syntax to make sure you have no errors.

1. Click the CheckBoxNo field and add this script to the mouse up event"Please enter the correct name.");

2. With this check box still selected, add this script to the Change event.

TextFieldName.rawValue = "";

CheckBoxYes.presence = "invisible";

3. Click the CheckBoxYes field and add this script to the change event

TextFieldName.rawValue = name1.value;

CheckBoxNo.presence = "invisible";

Run a test and you should see the question field and the check box fields show and hide when they are clicked.

About the contributor

Eugene Williams
Eugene is a contributing Acrobat User Group expert that has responded to over 500 questions posted by members of this user group. He was responsible for the founding of the, now inactive, Acrobat User Group, Las Vegas Chapter. He's currently working on revising his Joomla web site and supporting users of Acrobat Pro. Click this link to review my profile at


Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License