How to Populate a PDF Text Field from a Drop-Down List
Question details
The user wants to automatically fill a non-editable PDF text field with specific information (such as a ZIP code) based on the selection made in a drop-down list.

- Product
- PDF Forms
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where a drop-down menu selection triggers the automatic population of related data in other text fields.
- Observed behavior
- The user needs the correct JavaScript calculation script and form field property settings to ensure the destination text field updates automatically when a drop-down item is selected.
Ensure you are using a PDF editor that supports form creation and custom JavaScript. Verify that you have the exact names of your target drop-down and text fields noted down before adding the scripts.
Auto-Populate Text Fields Using a Calculation Script
This method assigns hidden values to drop-down items and uses a simple script in the target text field to fetch and display that value automatically.
This is the standard approach for populating a single text field based on a drop-down choice. You will assign the related data (like a ZIP code) as the drop-down's export value, then use a script to pull that export value into the text box.
Open the drop-down field's Properties and navigate to the Options tab. Add your items and set the related data (e.g., the specific ZIP code) as the 'Export Value' for each corresponding item.
While still in the drop-down's Options tab, ensure the 'Commit selected value immediately' checkbox is checked. This ensures the text field updates the moment an option is clicked.
Open the destination text field's Properties and navigate to the Calculate tab. Select 'Custom calculation script' and enter the following code: event.value = this.getField("Exact_Dropdown_Name").valueAsString;
Replace "Exact_Dropdown_Name" in the script with the exact name of your drop-down field. Close the properties dialog, save the PDF, and test the drop-down to ensure the text field populates correctly.

Populate Multiple Text Fields Using a Data Object Script
Use this advanced approach if a single drop-down selection needs to fill multiple different text fields simultaneously (e.g., Description and Cost).
Create and Edit Interactive PDF Forms with WPS Office
WPS Office provides comprehensive PDF editing tools, allowing you to easily insert drop-down lists, text fields, and manage interactive form properties without complex and expensive software.
- 1. Open your PDF Document: Launch WPS Office and open the PDF document where you want to add or modify form fields.
- 2. Navigate to the Form Tools: Click on the 'Form' tab located in the top ribbon menu to reveal the interactive form controls.
- 3. Insert Form Fields: Use the 'Combo Box' tool to insert your drop-down list, and the 'Text Field' tool to place your destination fields on the page.
- 4. Configure Properties: Double-click the inserted fields to open their properties dialogs, where you can easily configure options, export values, and calculation scripts.

Frequently Asked Questions
Why is my text field not updating when I change the drop-down?
This usually happens if the 'Commit selected value immediately' option is not enabled in the drop-down field's properties. Without this setting enabled, the calculation script won't trigger until you click completely outside the drop-down field.
Can I make the destination text field read-only?
Yes. Open the destination text field's properties, go to the 'General' tab, and check the 'Read Only' box. The calculation script will still be able to populate the field in the background, but users will not be able to click and type in it manually.
How do I fix a syntax error in my PDF JavaScript?
Double-check your custom calculation script for missing semicolons, unmatched parentheses, or incorrect quotation marks. Ensure field names inside the this.getField() command match exactly, including capitalization, as JavaScript is strictly case-sensitive.
Can I populate text fields from a drop-down without using JavaScript?
Unfortunately, standard PDF form specifications require JavaScript to dynamically transfer values from a drop-down selection into a separate text field. Built-in property settings alone cannot map values between distinct fields without a calculation or keystroke script.




