PDF Editing Issues

Get the New Combo Box Selection in Acrobat JavaScript

Camila MilosovichCamila Milosovich Nov 18, 2026 869 views

Question details

Find the newly selected combo box value or index in an Acrobat JavaScript form.

Get the New Combo Box Selection in Acrobat JavaScript
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the field properties

In Acrobat, open Prepare a Form, right-click the triggering combo box, and select Properties.

2
Inspect the validation script

Open the Validate tab and edit the custom validation script. Confirm that it is attached to the combo box whose selection is changing.

3
Use the proposed value

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; } }

4
Test the selection

Close the properties dialog, preview the form, and select different options. Check the resulting value or index in the JavaScript console.

Read the proposed selection in the validation event
Check option values: The example compares event.value with export values and returns the first match. Confirm whether your event supplies an export or display value; use getItemAt(i, false) for display values. Duplicate values or a typed entry may not identify a unique option.
Free Microsoft Office alternative

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.

Open and work with PDF documents in one office suiteCompatible with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXFamiliar interface for a smoother move from Microsoft OfficeFree, lightweight tools for everyday document work
microsoft office alternative - wps office

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.