How to Check Multiple PDF Checkboxes with One Button Using JavaScript
Question details
The user needs to configure a single button in a PDF form to sequentially check three checkboxes one by one with each click, while also triggering a radio button when the first checkbox is selected.

- Product
- Device & OS
- not provided
- Scenario
- Developing an interactive PDF form that requires automated, sequential field selections triggered by user clicks.
- Observed behavior
- The user wants to implement a specific sequence where each click of a push button selects the next checkbox in a series, and the first click simultaneously activates an associated radio button.
Ensure your PDF editing software supports JavaScript execution and form field editing. Note down the exact field names and export values for your checkboxes, radio button, and the push button before writing the script.
Use a Mouse Up JavaScript on the Push Button
This solution involves writing a custom JavaScript attached to the button's Mouse Up event to track the number of clicks and update the states of the target checkboxes and radio button accordingly.
To achieve a sequential selection in a PDF form, you must maintain a counter that remembers how many times the button has been clicked. Based on this counter, the script assigns the 'Export Value' to the corresponding checkbox to mark it as checked.
Open your PDF document in a compatible PDF editor. Access the form editing tools to make the form fields selectable and editable.
Double-click the push button that you want to use as the trigger. This will open the Button Properties dialog box.
Navigate to the 'Actions' tab. Choose 'Mouse Up' from the Select Trigger dropdown menu. Next, choose 'Run a JavaScript' from the Select Action dropdown and click 'Add'.
In the JavaScript editor, initialize a counter variable if it doesn't exist (e.g., check if typeof clickStep == 'undefined'). Increment this counter with each click.
Use an if-else statement or switch case based on the counter. On step 1, set the first checkbox and the radio button to their respective export values (e.g., this.getField('CheckBox1').value = 'Yes'). On step 2, set the second checkbox, and on step 3, set the third checkbox.

Create and Edit Interactive PDF Forms with WPS Office
WPS Office provides comprehensive PDF editing tools that allow you to easily insert buttons, checkboxes, radio buttons, and text fields into your documents while ensuring seamless compatibility with standard PDF viewers.
- 1. Open your PDF: Launch WPS Office and open your existing PDF document or create a new one.
- 2. Navigate to the Form tab: Click on the 'Form' tab on the top ribbon to access all interactive form controls.
- 3. Insert Form Controls: Select 'Push Button', 'Check Box', or 'Radio Button' and click on the page to place them.
- 4. Edit Properties: Double-click any inserted field to adjust its name, appearance, and export values.
- 5. Save the Document: Save your PDF to preserve the interactive form fields for your users.

Frequently Asked Questions
Why isn't my JavaScript executing when I click the button?
Ensure that JavaScript is enabled in your PDF viewer's security preferences. Additionally, verify that your code is assigned to the 'Mouse Up' trigger rather than 'Mouse Down', as 'Mouse Up' is the standard behavior for triggering button actions in PDFs.
How do I find the correct export value for a PDF checkbox?
Open the Checkbox Properties in your PDF editor, navigate to the 'Options' tab, and look for the 'Export Value' field. By default, this is often set to 'Yes'. Your JavaScript must use this exact string to check the box.
Can I group radio buttons so only one can be selected?
Yes. To group radio buttons together, give them the exact same field name but assign a different 'Export Value' to each. This ensures they behave as a mutually exclusive group.
How do I uncheck a checkbox using JavaScript?
To uncheck a checkbox via JavaScript, set its value to 'Off'. For example: this.getField('YourCheckboxName').value = 'Off';




