How to Auto-Populate a Text Field Based on a PDF Dropdown Choice
Question details
The user wants to configure a PDF form so that selecting an option in a choice field automatically displays a corresponding descriptive text in a separate text field.

- Product
- PDF Form Editor
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where a text output field needs to dynamically update its content based on the user's selection from a dropdown list.
- Observed behavior
- The user requires a method or script to map specific dropdown choices to targeted string outputs in another form field.
Ensure you are using a PDF editor that supports form field creation and custom JavaScript calculations. You should already have your dropdown field (Choice_01) and text field (Output_01) created on the document.
Use a Custom JavaScript Calculation Script
Add a custom calculation script to the output text field that reads the selected value from the dropdown menu and assigns the corresponding descriptive text.
Interactive PDF forms rely on JavaScript to pass data between fields. By assigning a calculation script to the target text field, it will automatically listen for changes in your specified choice field and update its own value according to the logical conditions you define.
Enter PDF form editing mode. Right-click on the target text field (e.g., Output_01) and select 'Properties' from the context menu.
In the Properties dialog box, click on the 'Calculate' tab to set up the field's calculation behavior.
Select the 'Custom calculation script' radio button, click the 'Edit' button, and paste the conditional script. For example: var cChoice = this.getField("Choice_01").valueAsString; if (cChoice == "Item 1") event.value = "Description for Item 1"; else if (cChoice == "Item 2") event.value = "Description for Item 2"; else event.value = "";
Click 'OK' to save the script, then close the Properties window. Exit form editing mode and select different options in your dropdown field to verify that the text field updates automatically.

Create Interactive PDF Forms with WPS Office
WPS Office offers a powerful, user-friendly PDF editor that makes inserting form controls, mapping properties, and handling calculations straightforward and intuitive.
- 1. Open the PDF Module: Launch WPS Office and open your PDF document using the built-in PDF editor.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access interactive elements like Text Fields and Drop-Down Lists.
- 3. Configure Properties: Double-click any inserted form field to open the Properties menu, where you can define names, appearances, and calculation scripts.
- 4. Save and Share: Once your interactive fields are mapped, save the PDF to share a fully functional interactive form with others.

Frequently Asked Questions
Why is the text field not updating when I select a new dropdown option?
This usually happens if JavaScript execution is disabled in your PDF reader's security preferences, or if the field names referenced in the custom calculation script do not perfectly match the actual field names on the document. Double-check your spelling and capitalization.
Can I link multiple text fields to a single dropdown choice field?
Yes. You can add unique custom calculation scripts to as many text fields as you need. Each script simply needs to reference the same choice field but assign different output strings based on your logic.
How do I add a default blank option to the dropdown list?
Open the dropdown field's Properties, go to the Options tab, enter a single space or leave the 'Item' name blank, and click Add. In your calculation script, add a condition like 'else if (cChoice == " ") event.value = "";' to clear the text field when the blank option is selected.




