How to Link Checkboxes to Combo Box Values with PDF JavaScript
Question details
The user needs to dynamically control the selected value of a combo box in a PDF form using a group of mutually exclusive checkboxes.

- Product
- PDF Form Editor
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where checking a specific box automatically populates a related dropdown combo box with the corresponding value.
- Observed behavior
- A custom JavaScript calculation script must be written to read the export value of the selected checkbox and assign the matching value to the combo box.
Ensure your PDF editor supports JavaScript for form fields. Check that your checkboxes share the same field name but have distinct export values, which makes them mutually exclusive.
Apply a Custom Calculation Script to the Combo Box
Use a JavaScript calculation snippet inside the combo box properties to evaluate the checkbox group and set the dropdown value dynamically.
By assigning a custom calculation script to the combo box, the PDF viewer will continuously monitor the state of the target checkbox group. When a user selects a checkbox, the script checks its export value and updates the combo box's displayed value accordingly.
Launch your PDF form editor and activate the form editing or preparation mode to reveal all field properties.
Right-click the target Combo Box (e.g., 'Program Select') and select 'Properties' from the context menu.
In the Properties dialog, click on the 'Calculate' tab to view calculation options for the field.
Select 'Custom calculation script' and click 'Edit'. Paste the following code: var c = this.getField("ProgramCheck").valueAsString; if (c == "Program1") event.value = "Course1"; else if (c == "Program2") event.value = "Course2"; else if (c == "Program3") event.value = "Course3"; else if (c == "Program4") event.value = "Course4"; else if (c == "Program5") event.value = "Course5"; else event.value = "-";
Click 'OK' to save the script, close the Properties window, and exit form editing mode to test the checkbox interactions.

Edit and Manage Interactive PDF Forms with WPS Office
WPS Office provides a comprehensive PDF editor that allows you to effortlessly design, modify, and fill interactive PDF forms, ensuring compatibility and ease of use.
- 1. Open Your PDF: Launch WPS Office and open your existing PDF document or create a blank one.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to reveal the interactive field tools.
- 3. Add Form Fields: Click on the Check Box or Combo Box icons, then drag on the page to place them into your document.
- 4. Modify Field Properties: Double-click the newly placed field to adjust its name, export values, and formatting rules.

Frequently Asked Questions
Why isn't my combo box updating when I click the checkbox?
This usually happens if the field names or export values in the script do not perfectly match the actual properties of your checkboxes. Ensure exact spelling and case-sensitivity for both the 'getField' target and the 'event.value' assignments.
How do I make checkboxes mutually exclusive?
To make checkboxes mutually exclusive (behaving like radio buttons), give all checkboxes in the group the exact same 'Name' in their properties, but assign a different, unique 'Export Value' to each one.
Does this JavaScript code work on mobile PDF viewers?
Not always. While desktop applications like Adobe Acrobat and WPS Office PDF handle custom calculation scripts perfectly, many basic mobile PDF viewers do not support advanced JavaScript processing.
Can I link multiple different checkbox groups to one combo box?
Yes, but your JavaScript will need to be expanded with additional logic (such as nested if/else statements or logical operators) to read the states of all required field groups before calculating the final combo box value.




