How to Use Radio Buttons to Select or Clear Checkboxes in PDF Forms
Question details
The user wants to automate checkbox selections in a PDF form so that selecting a specific radio button checks certain boxes, while selecting other options clears them.
- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where two checkboxes (cbWage and cbTax) need to automatically check or uncheck based on the selected option within a radio-button group (Type).
- Observed behavior
- By default, the checkboxes and radio buttons operate independently, requiring a custom script to link their behavioral states together.
Ensure you are using a PDF editor that supports adding custom JavaScript to form fields. Take note of the exact field names of your radio button group and checkboxes, as well as their specific export values.
Add a Custom JavaScript to the Radio Button Group
Use a custom mouse-up script to dynamically change the checkbox states when a specific radio button is selected.
By assigning a JavaScript action to the radio button group, you can control other fields in the document. When the user clicks an option, the script evaluates the selection and updates the targeted checkboxes automatically.
Open your PDF form in editing mode. Locate the radio button group (e.g., 'Type'), right-click it, and select 'Properties'.
Navigate to the 'Actions' tab. Choose 'Mouse Up' from the Select Trigger dropdown, and select 'Run a JavaScript' from the Select Action dropdown. Click the 'Add' button.
In the JavaScript editor, input the following code: var online = this.getField('Type').valueAsString == 'Online'; this.getField('cbWage').value = online ? 'Yes' : 'Off'; this.getField('cbTax').value = online ? 'Yes' : 'Off';
Make sure to replace 'Yes' in the script with the actual export value configured in your checkboxes' Options tab. Click 'OK' to save the script, then test the form to ensure the checkboxes respond correctly.

Easily Manage Interactive PDF Forms with WPS Office
WPS Office provides a comprehensive suite of PDF tools, allowing you to view, fill, and manage interactive PDF forms effortlessly without needing expensive software.
- 1. Open your PDF: Launch WPS Office and open your interactive PDF document.
- 2. Access form tools: Navigate to the 'Form' tab on the top ribbon to view all available form editing and filling tools.
- 3. Interact with fields: Easily click on checkboxes, radio buttons, and text fields to fill out your form accurately.
- 4. Save and export: Once completed, save your document securely or export it as a flattened PDF to preserve your selections.

Frequently Asked Questions
Why aren't my checkboxes clearing when I select a different radio button?
This usually happens if the JavaScript isn't triggered correctly. Ensure the script is attached to the entire radio button group's 'Mouse Up' action, rather than just an individual button.
How do I find the correct export value of my checkbox?
Right-click the checkbox in form editing mode, select Properties, and go to the Options tab. The 'Export Value' field will display the exact text you need to use in your script (e.g., 'Yes', 'Checked', or '1').
Can I apply this script to multiple checkbox groups at once?
Yes. You can expand the JavaScript snippet by referencing additional field names using the this.getField('FieldName').value method for as many checkboxes as your form requires.




