How to Display a PDF Combo Box Export Value with JavaScript
Question details
The user needs to retrieve and display the selected export value from a combo box field in a PDF using JavaScript.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating or editing interactive PDF forms requiring custom JavaScript calculations.
- Observed behavior
- The user wants a JavaScript solution to successfully extract a combo box's chosen export value as text.
Ensure that your PDF document contains a combo box form field with predefined export values, and that your PDF editor supports custom JavaScript actions.
Use the valueAsString Property to Retrieve the Export Value
You can extract the exact export value by targeting the combo box field and utilizing the valueAsString property in your JavaScript code.
When dealing with interactive PDF forms, combo boxes often display one set of text to the user while storing a different underlying 'export value' for calculations or backend data handling. Accessing this value requires a specific scripting approach.
Open your PDF form in editing mode. Right-click the target field where you want to display the value, select 'Properties', and navigate to the 'Calculate' or 'Action' tab to enter a custom JavaScript.
Declare a variable to reference your combo box by its exact name. For example: var field = this.getField("ComboBox1");
Use the valueAsString property to get the text of the export value and assign it to the current event. Add this line: event.value = field.valueAsString;
Close the script editor, exit form editing mode, and test the combo box. The target field should now automatically update to display the chosen item's export value.

Easily Manage PDF Forms and Fields in WPS PDF
WPS Office offers a comprehensive suite of PDF tools, allowing you to easily insert, edit, and configure interactive form fields such as combo boxes, text boxes, and buttons without needing complex scripting.
- 1. Open your PDF in WPS: Launch WPS Office, click on 'PDF', and open your interactive PDF document.
- 2. Access the Form tab: Navigate to the 'Form' tab in the top ribbon to reveal the interactive form toolkit.
- 3. Edit the Combo Box: Select the 'Combo Box' tool. Double-click the existing combo box to open its properties and easily define or modify display items and their export values.
- 4. Save changes: Click 'Save' to apply your adjustments. You can preview the interactive elements immediately within the WPS PDF viewer.

Frequently Asked Questions
What is an export value in a PDF combo box?
An export value is the specific background data tied to a selection in a combo box. While a user might see a descriptive label in the dropdown menu, the PDF script or form data extraction process uses the shorter or numerically formatted export value.
Why does my JavaScript return the display text instead of the export value?
Depending on the PDF viewer and how the standard 'value' property is accessed, the form may default to returning the face text. Using 'valueAsString' explicitly commands the script to retrieve the underlying chosen export value instead.
Can I use the retrieved export value in a calculation?
Yes. Once you retrieve the export value using valueAsString, you can convert it to a number using JavaScript functions like Number() or parseFloat(), and then use it in standard mathematical operations for order forms or invoices.




