How to Dynamically Populate a PDF Dropdown from Text Fields
Question details
The user wants to configure a PDF dropdown menu to automatically pull and display options based on inputs typed into nearby text fields, while also allowing users to manually type their own custom text into the dropdown.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Designing an advanced interactive PDF form where dropdown options change dynamically based on user input elsewhere on the form.
- Observed behavior
- The dropdown needs to automatically aggregate values from specific text fields via a custom script and accept custom manual text entry.
Ensure you are using a PDF editor that supports advanced form properties and JavaScript calculations, and verify that your target text fields follow a standardized naming convention (e.g., TextBox.1, TextBox.2) for the script to recognize them properly.
Enable Custom Manual Entry and Add a Calculation Script
Configure the dropdown properties to allow custom user input and insert a JavaScript calculation code to dynamically fetch values from related text fields.
To make the dropdown dynamic, you must first allow custom entries and then use a JavaScript array method in the calculation tab to filter and append the text field values to the dropdown options.
Enter the form editing or prepare mode in your PDF editor. Double-click the dropdown field you want to modify to open its Properties dialog box.
Navigate to the 'Options' tab within the Properties window. Check the box labeled 'Allow user to enter custom text' to ensure manual typing is supported.
Switch to the 'Calculate' tab in the same Properties window. Select the 'Custom calculation script' option and click the 'Edit' button.
Paste the calculation script to map your text field values. For example, if your fields are named 'TextBox.1', 'TextBox.2', use code like: if(/^TextBox/.test(event.source.name)){ var textData = this.getField('TextBox').getArray().map(function(a){return a.valueAsString;}); var cList = textData.filter(function(a){return (a.length > 0);}); event.target.setItems(cList); } Click OK and close to apply.

Easily Create and Edit Interactive PDF Forms with WPS Office
WPS Office provides a comprehensive PDF editor that lets you easily manage document forms, insert dropdown menus, add text fields, and manipulate PDF content without steep learning curves.
- 1. Open PDF Form in WPS Office: Launch WPS Office and open your existing PDF document or create a blank one.
- 2. Access Form Tools: Click on the 'Form' tab in the top navigation ribbon to reveal all interactive field options.
- 3. Insert Form Fields: Select 'Combo Box' for a dropdown menu or 'Text Field', then click anywhere on the page to place your form control.
- 4. Customize Field Properties: Double-click the inserted field to modify its appearance, set default options, and format the user inputs.

Frequently Asked Questions
Why is my PDF dropdown menu not updating when I type in the text fields?
If the dropdown does not update dynamically, ensure the calculation order is correct in your form settings. The text fields must be calculated or processed before the dropdown script runs. Additionally, verify that the field names exactly match the names defined in your JavaScript code.
Can I add fixed items to the dropdown without using scripts?
Yes. If you do not need dynamic population, you can manually add fixed choices by opening the dropdown Properties, going to the 'Options' tab, typing your choice in the 'Item' box, and clicking 'Add'.
Does allowing custom text permanently save the typed value in the form?
Yes, when 'Allow user to enter custom text' is checked, the custom value entered by the user becomes the current selected value for that field and will be preserved when the filled PDF is saved.




