Retrieve a Drop-Down List Item Value in Acrobat JavaScript
Question details
Retrieve the newly selected display and export values from an Acrobat PDF form drop-down using JavaScript.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A form author is writing a Keystroke script for a PDF drop-down field.
- Observed behavior
- During the Keystroke event, currentValueIndices and getItemAt can still refer to the previously committed selection.
Open the PDF in Acrobat and locate the drop-down field in Prepare a form. Check the field's Options to identify its item labels and export values.
Read the New Selection From the Keystroke Event
Use event properties to capture the incoming selection before it is committed.
When event.willCommit is false, event.change provides the incoming display value and event.changeEx provides its export value. The field's currentValueIndices and getItemAt may still reflect the previous committed selection.
In Acrobat, open Prepare a form, then double-click the drop-down field to open its properties.
On the Format tab, choose Custom from the format category list, then select Edit next to Custom Keystroke Script.
Enter: if (!event.willCommit) { console.println("Change=" + event.change + " Export=" + event.changeEx); }
Close the properties, open Acrobat's JavaScript console, and select an item in the drop-down. Check the console for the incoming display and export values.

Work With PDF Documents in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Microsoft Office files. Its format compatibility makes it easy to move everyday documents into WPS. Acrobat-specific JavaScript behavior still needs to be tested in Acrobat.

Frequently Asked Questions
Why does currentValueIndices show the previous drop-down selection?
During a Keystroke event, the new selection may not yet be committed. When event.willCommit is false, use event.change for the incoming display value and event.changeEx for the incoming export value.
Where do I add a Keystroke script to a drop-down field?
In Acrobat, open Prepare a form and double-click the field. On the Format tab, select the Custom format category and edit the Custom Keystroke Script.
How do I check an item's export value?
Open the drop-down field's properties in Prepare a form and check the item settings on the Options tab. In a Keystroke script, event.changeEx supplies the incoming export value.
Does this script export the selection to CSV?
No. It prints the incoming values to Acrobat's JavaScript console. CSV export is a separate task that requires additional scripting; creating a CSV attachment generally requires Acrobat Pro.




