How to Show Different PDF Form Text Based on a Dropdown Selection
Question details
The user wants to automatically populate specific text fields in a PDF form depending on the choice made in a dropdown menu.

- Product
- PDF Form Editor
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where text fields need to dynamically update their content based on what a user selects from a dropdown list.
- Observed behavior
- The goal is to map each dropdown value to a corresponding text string and display that string in a designated target field upon selection.
Ensure that your PDF editing software supports JavaScript for form calculations and that you have noted the exact names of your target text fields.
Use a Custom Validation Script with JavaScript Objects
Apply a custom JavaScript validation script to the dropdown field to map user selections to specific text strings and populate the target field.
By utilizing a JavaScript object as a dictionary or map, you can easily pair dropdown options with their corresponding text descriptions. When the user makes a selection, the script reads the choice, looks up the mapped text, and pushes it to your designated text field.
Open your PDF document in your PDF editor and activate the form editing or preparation mode.
Right-click the dropdown field (Combo Box) you want to use as the trigger and select 'Properties'.
Click on the 'Validate' tab within the Properties window, select the 'Run custom validation script' option, and click the 'Edit' button.
Enter the following script, adjusting the field name and options to match your form: var o = {"Apples": "Big and red", "Oranges": "Round and sweet", "Pears": "Like apples"}; this.getField("Text Field 1").value = o[event.value];
Click 'OK' to close the script editor, exit form editing mode, and select different options in your dropdown to verify the target text field updates automatically.

Create Interactive PDF Forms with WPS Office
WPS Office provides a comprehensive PDF editor that lets you quickly insert dropdowns, text fields, and checkboxes to build professional, interactive PDF forms.
- 1. Open Your PDF in WPS: Launch WPS Office and open your PDF document using the integrated PDF editor.
- 2. Access the Form Tools: Navigate to the 'Form' tab on the top ribbon to reveal the interactive form creation toolkit.
- 3. Add Dropdowns and Text Fields: Click 'Combo Box' to insert your dropdown menu, and 'Text Field' for the areas where dynamic text will appear.
- 4. Customize Field Properties: Double-click the inserted form fields to adjust their names, appearance, and underlying property options.

Frequently Asked Questions
Can I map text to multiple text fields from one dropdown selection?
Yes. You can expand your custom validation script by adding more lines for different fields. For example, add this.getField('Text Field 2').value = anotherObject[event.value]; right below your first mapping line.
Why isn't my target text field updating after making a dropdown selection?
This commonly happens if the target field name in your script doesn't exactly match the actual field name in the PDF properties, or if JavaScript execution is restricted by the PDF reader's security settings.
Can I show and hide fields instead of just altering text?
Yes. Instead of changing the value property, you can manipulate the display property. Using a similar script, you can set this.getField('Text Field 1').display = display.hidden; or display.visible based on the dropdown choice.
Will these custom JavaScript interactions work on mobile PDF readers?
It depends on the app. While standard desktop applications like WPS Office and Adobe Acrobat fully support JavaScript in PDF forms, many mobile PDF viewers have limited or no support for executing custom validation scripts.




