How to Link Checkboxes and Radio Buttons with JavaScript in PDF
Question details
The user needs to connect an applicability checkbox to a group of radio buttons using JavaScript within a PDF form.

- Product
- PDF Form Editor
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF questionnaire with dependent form fields.
- Observed behavior
- Selecting a radio button answer automatically checks the associated applicability checkbox, and unchecking the checkbox clears the selected answers in the radio button group.
Ensure you are using a PDF editor that supports form field creation and custom JavaScript execution, and confirm all your form fields have distinct, finalized names before applying scripts.
Configure JavaScript Actions for Radio Buttons and Checkboxes
Apply custom JavaScript actions to the individual form fields to synchronize their behavior, ensuring selections trigger the correct checkbox state.
This method relies on assigning specific Mouse Up actions to your form controls. By executing a script when a user interacts with a field, you can dynamically control the values of other related fields in the same document.
Open your PDF editor's form preparation mode. Ensure your checkbox and radio button group have recognizable, unique names (e.g., 'ApplicabilityCheck' and 'AnswerGroup'). Verify that all radio buttons in the group share the same field name but have distinct export values.
Right-click a radio button and select Properties. Navigate to the Actions tab, select 'Mouse Up' as the trigger, and choose 'Run a JavaScript'. Enter a script that sets the associated checkbox's value to true or 'Yes' when the radio button is clicked. Repeat this for each radio button in the group.
Open the Properties for the checkbox. Under the Actions tab, add a 'Mouse Up' trigger to run a JavaScript. Input code that evaluates whether the checkbox is unchecked, and if so, resets the 'AnswerGroup' radio buttons to an 'Off' or empty state.
Exit the form editing or preparation mode. Click the radio buttons to verify the checkbox automatically fills, then uncheck the checkbox to ensure the radio button selections are properly cleared.

Create and Manage Interactive PDF Forms with WPS Office
WPS Office provides a comprehensive, easy-to-use PDF toolkit that allows you to quickly insert checkboxes, radio buttons, and other interactive form controls into your documents.
- 1. Open your PDF: Launch WPS Office and open your PDF document using the built-in PDF editor.
- 2. Access form tools: Navigate to the 'Form' tab on the top ribbon to view the available interactive form controls.
- 3. Insert form controls: Click on the Checkbox or Radio Button icons and drag them onto your document space to create the required fields.
- 4. Modify field properties: Double-click the inserted field to open the Properties panel, where you can configure its name, appearance, and basic export values.

Frequently Asked Questions
Why isn't my JavaScript action triggering when I click the radio button?
This typically happens if the trigger event is configured incorrectly. Ensure your action is set to 'Mouse Up' instead of 'Mouse Down'. 'Mouse Up' registers after a full click has been completed, making it the standard trigger for interactive PDF elements.
How do I clear a group of radio buttons using a JavaScript command?
You can clear a radio button group by resetting its field value in your custom script. Typically, using a command like `this.getField('YourRadioGroupName').value = 'Off';` will uncheck all buttons in that specific group.
Do I need advanced programming experience to create PDF forms?
No, creating standard interactive forms only requires dragging and dropping fields using a PDF editor. However, linking fields with custom conditional logic—such as auto-checking boxes based on other selections—does require basic knowledge of JavaScript syntax.




