PDF Editing Issues

How to Populate Acrobat Dropdown Lists from Text Fields Using JavaScript

Chanuka GeekiyanageChanuka Geekiyanage Nov 3, 2026 869 views

Question details

The user wants to dynamically populate repeated PDF dropdown fields with names entered in two separate text fields, ensuring the dropdown updates whenever the text field values change.

How to Populate Acrobat Dropdown Lists from Text Fields Using JavaScript
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating dynamic PDF forms where dropdown list items depend on user input from other text fields.
Observed behavior
The dropdown options need to automatically update with the exact values entered into the designated text fields.
Before you start

Ensure you have access to the 'Prepare Form' tools in Adobe Acrobat and basic familiarity with adding custom JavaScript to form fields.

Solution 1Recommended

Apply Custom Validation Scripts to Text Fields

Use JavaScript to trigger an update to the dropdown menu whenever the user inputs a value into the text fields.

This method leverages custom validation scripts applied directly to the text fields. When a text field's value changes, the script updates the items available in the target dropdown field.

1
Open form editing mode

Open your PDF in Adobe Acrobat and enter the 'Prepare Form' mode to view all your interactive form fields.

2
Add script to the first text field

Right-click the first text field (e.g., 'name1') and select 'Properties'. Go to the 'Validate' tab and select 'Run custom validation script'. Enter the following JavaScript: this.getField('NameSelection').setItems(['', event.value, this.getField('name2').valueAsString]);

3
Add script to the second text field

Right-click the second text field (e.g., 'name2') and select 'Properties'. Under the 'Validate' tab, enter the following custom validation script: this.getField('NameSelection').setItems(['', this.getField('name1').valueAsString, event.value]);

4
Adjust field names

Replace 'NameSelection' in the code with the actual field name of your dropdown list. Ensure the text field names ('name1' and 'name2') exactly match the field names in your document.

Apply Custom Validation Scripts to Text Fields
Resetting Selections: Keep in mind that triggering this validation script will reset any existing selections made in the dropdown fields whenever either text field is changed.
Powerful PDF Form Editing

Edit and Manage PDF Forms Easily with WPS Office

WPS Office provides a comprehensive PDF editor that allows you to create, edit, and fill interactive PDF forms efficiently without needing expensive software.

  1. 1. Open WPS PDF: Launch WPS Office and open your PDF document using the built-in PDF Editor.
  2. 2. Access form tools: Navigate to the 'Form' tab to view all interactive form controls like Text Fields, Checkboxes, and Dropdown Menus.
  3. 3. Edit field properties: Double-click any form field to open its Properties panel, where you can configure options, formatting, and interactive behaviors.
Seamless compatibility with standard PDF form fieldsUser-friendly interface for designing interactive formsExcellent compatibility with Microsoft Office formatsLightweight and completely free alternative for daily document tasks
microsoft office alternative - wps office

Frequently Asked Questions

Why does my dropdown selection reset when I type in the text field?

Because the JavaScript validation script uses the setItems method to completely rebuild the dropdown's list of options. When this happens, any previously selected value in the dropdown is cleared.

Can I populate multiple dropdown fields at the same time?

Yes. If your dropdown fields have different names, you can update each one separately within the same script by adding a setItems line for each target field, or use a document-level script to loop through them.

What if I want more than two text fields to feed into the dropdown?

You can expand the array inside the setItems function. Just add additional this.getField('nameX').valueAsString elements into the array for every new text field you want to include in the dropdown options.