Get the New Combo Box Selection in Acrobat JavaScript
Question details
Find the newly selected combo box value or index in an Acrobat JavaScript form.

- Product
- Adobe Acrobat JavaScript
- Device & OS
- not provided
- Scenario
- A PDF form script needs to react to a change in a combo box with immediate value commit enabled.
- Observed behavior
- The script reads the previous selection index instead of the newly selected index.
Open the PDF in Acrobat's Prepare a Form tool and identify the combo box that triggers the script. Check whether the script is attached to its validation, keystroke, calculation, or another event.
Read the proposed selection in the validation event
Use the validation event when the script needs the new value before Acrobat finishes committing it.
Immediate value commit does not make currentValueIndices update before every event script runs. In a validation script attached to the changed combo box, event.value contains the proposed value; use it rather than relying on the field's previously committed index.
In Acrobat, open Prepare a Form, right-click the triggering combo box, and select Properties.
Open the Validate tab and edit the custom validation script. Confirm that it is attached to the combo box whose selection is changing.
In the validation script, read event.value. If you need an index, compare it with the field's option values: var f = event.target; var selected = String(event.value); var index = -1; for (var i = 0; i < f.numItems; i++) { if (String(f.getItemAt(i, true)) === selected) { index = i; break; } }
Close the properties dialog, preview the form, and select different options. Check the resulting value or index in the JavaScript console.

Read the combo box index after the selection is committed
Use this approach when the index can be checked in a later user action, such as clicking a button.
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 Office documents. Its format support makes moving everyday files easier, but it does not debug or fix Acrobat JavaScript events.

Frequently Asked Questions
Why does currentValueIndices show the previous selection?
The script may run before Acrobat commits the new selection. In a validation script, use event.value for the proposed value, or read currentValueIndices in a later action after the commit.
Does committing the selected value immediately change event order?
No. The option commits the selection without waiting for the user to leave the field, but validation and keystroke scripts can still run before the new field value is committed.
How can I find which field triggers the script?
In Prepare a Form, open each relevant field's Properties and inspect its Actions, Validate, and Calculate tabs. In a validation script, event.target identifies the field being validated.
Can I get the new selection during a keystroke event?
For a dropdown selection in a keystroke event, inspect event.change for the displayed choice and event.changeEx for its export value. The event can run at different stages, so check event.willCommit and test the behavior for your form.
Are combo box indices zero-based?
Yes. The first option has index 0. Use currentValueIndices after commit, or compare the proposed value with options using getItemAt(index, true) for export values.




