Run PDF JavaScript Immediately After a Drop-Down Selection in Adobe Acrobat
Question details
Run a PDF form script as soon as a user selects an item in the first drop-down so that a second drop-down updates immediately.

- Product
- PDF form JavaScript; Adobe Acrobat form editor
- Device & OS
- not provided
- Scenario
- A PDF form has dependent drop-down fields, and the second field's choices depend on the first field's selection.
- Observed behavior
- The second drop-down does not update until focus leaves the first field.
Open the PDF in a form editor that supports field validation scripts, such as Adobe Acrobat Pro. Check the exact field names and the display and export values of the first drop-down's items.
Use a Validate script and commit the drop-down value immediately
Use this approach when a dependent field updates only after the user leaves the first drop-down.
The Validate action runs when the selected value is committed. Enabling immediate commitment triggers the action as soon as the user makes a selection.
In the validation script, use event.value for the value being committed. Make sure the values compared in the script match the configured choices; if using display text, keep the corresponding export values identical.
In Adobe Acrobat Pro, open the PDF and choose All tools > Prepare a form. Double-click the first drop-down field to open its properties.
On the Options tab, select Commit selected value immediately.
On the Validate tab, select Run custom validation script and click Edit. Move the existing update script there, or enter a script that checks event.value and calls setItems() on the second field. Replace field names and choice values with those from your form.
Close the properties, preview the form, and select each item in the first drop-down. Confirm that the second drop-down updates without clicking outside the first field, then save the PDF.

Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Microsoft Office files. It makes moving between common document formats easy, but it does not replace Acrobat's PDF form JavaScript configuration for this fix.

Frequently Asked Questions
Why does the second drop-down update only after I click elsewhere?
The first field's value may not be committed until it loses focus. In its Properties > Options tab, select Commit selected value immediately and place the update script in the Validate action.
Which value should the validation script check?
Use event.value to read the value being committed. Check the first drop-down's item settings and ensure the values in your script match its configured display and export values.
Can multiple selections produce the same list in the second field?
Yes. In the first field's Validate script, group those cases or point them to the same item list before calling setItems() on the second field.
Why does the script work in Acrobat but not in a browser?
Some browser PDF viewers do not support PDF form JavaScript. Test the saved form in Acrobat or Acrobat Reader, and check Preferences > JavaScript to confirm that Acrobat JavaScript is enabled.




