Populate PDF Form Fields from a Dropdown in Adobe Acrobat
Question details
Automatically populate location details in separate PDF form fields when a user selects a location from a dropdown.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form has a dropdown of locations and separate fields for the location name, address, telephone number, and fax number.
- Observed behavior
- Selecting a location should fill the corresponding fields with its details, while an unrecognized selection should clear them.
Open the PDF in an Acrobat edition that can edit form fields, and note the exact names of the dropdown and destination fields. Check each dropdown option's export value, if one is set, because the script must match the value Acrobat submits.
Add a validation script to the Acrobat dropdown
Use a dropdown validation script to fill the related fields as soon as a location is selected.
Open the PDF in Adobe Acrobat, choose All tools > Prepare a form, and open the dropdown field's Properties.
In the dropdown Properties window, select the Options tab and enable Commit selected value immediately.
On the Validate tab, select Run custom validation script and click Edit. Paste the following script, then replace the example field names, dropdown values, and location details with your own: var f1 = this.getField("Location Name"); var f2 = this.getField("Address"); var f3 = this.getField("Telephone"); var f4 = this.getField("Fax"); switch (event.value) { case "Location1": f1.value = "Location1 Name"; f2.value = "Location1 Address"; f3.value = "Location1 Telephone"; f4.value = "Location1 Fax"; break; case "Location2": f1.value = "Location2 Name"; f2.value = "Location2 Address"; f3.value = "Location2 Telephone"; f4.value = "Location2 Fax"; break; default: f1.value = ""; f2.value = ""; f3.value = ""; f4.value = ""; }
Close the Properties window, save the PDF, and use Preview in Prepare a form to select each location. Check that all four fields update and that an unmatched or blank choice clears them.

Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with Office documents and PDFs. Its format compatibility makes it easy to bring existing files into your workflow. Use Acrobat for the dropdown validation script described above.

Frequently Asked Questions
Why don't the fields update when I select a location?
In the dropdown's Properties > Options, enable Commit selected value immediately. Also check that each getField name matches a form field and that each case matches the option's export value, if set.
How do I add another location?
Open the dropdown's Properties > Validate > Edit and add another case before default. Set values for all four fields and end the case with break.
How can I clear the fields when no location is selected?
Keep the default section of the validation script, which assigns an empty string to each field. A blank or other unmatched dropdown value will run that section.
Will this script work in every PDF viewer?
No. The viewer must support Acrobat form JavaScript, and its settings may affect whether scripts run. Test the saved PDF in the viewer your recipients will use.




