Automatically Fill Phone and Email Fields from a PDF Drop-Down in Adobe Acrobat
Question details
Automatically populate phone and email fields when a user selects a city in a PDF drop-down list.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form contains a city drop-down and separate phone and email fields for the selected location.
- Observed behavior
- Selecting a city should display the corresponding phone number and email address in the form.
Open the PDF in a version of Adobe Acrobat that supports editing form fields, and check the exact names of the drop-down, email, and phone fields. Note whether the drop-down uses export values that differ from the displayed city names.
Add a validation script to the Acrobat city drop-down
Use a custom validation script to assign contact details whenever the selected city is committed.
Open the PDF in Adobe Acrobat and choose All tools > Prepare a form. Create the city drop-down and the email and phone text fields if they do not already exist.
Open each field's Properties and check its name. In the drop-down's Options tab, check the values assigned to the city choices and enable Commit selected value immediately so the fields update when a choice is made.
Open the city drop-down's Properties, select the Validate tab, choose Run custom validation script, and click Edit. Enter this example: var emailTxt = ""; var phoneTxt = ""; if (event.value == "Marseille") { emailTxt = "Marseille@example.com"; phoneTxt = "0101010101010"; } else if (event.value == "Lyon") { emailTxt = "Lyon@example.com"; phoneTxt = "02020202020202"; } else if (event.value == "Paris") { emailTxt = "Paris@example.com"; phoneTxt = "03030303030303"; } this.getField("Email").value = emailTxt; this.getField("Phone").value = phoneTxt;
Replace the example city values, contact details, and the Email and Phone field names with those used in your form. Save the script and use Preview in Prepare a form to select each city and check both fields.

Work with PDF and Office documents in WPS Office
WPS Office is a free, lightweight alternative for working with PDF and Microsoft Office files in a familiar interface. Open compatible documents to make migration easier; use Adobe Acrobat to configure the PDF validation script described above.

Frequently Asked Questions
Why don't the contact fields update immediately after I select a city?
In Prepare a form, open the drop-down's Properties > Options and enable Commit selected value immediately. Then test the selection in Preview.
Should the script compare the city label or its export value?
Compare event.value with the value submitted by the drop-down. If a choice has an export value different from its displayed label, use that export value in the script.
How do I add another city?
Add the city to the drop-down under Properties > Options, then add another else-if block in the Validate tab's custom script with its value, email address, and phone number.
Will the form work in every PDF viewer?
No. The viewer must support and allow Acrobat JavaScript. Test the saved PDF in the viewer your recipients will use.




