PDF Editing Issues

How to Link Checkboxes and Radio Buttons with JavaScript in PDF

Nimra MalikNimra Malik Nov 3, 2026 869 views

Question details

The user needs to connect an applicability checkbox to a group of radio buttons using JavaScript within a PDF form.

How to Link Checkboxes and Radio Buttons with JavaScript in PDFs
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.
Before you start

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.

Solution 1Recommended

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.

1
Assign consistent field names

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.

2
Add action to radio buttons

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.

3
Add action to the checkbox

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.

4
Test the form logic

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.

Configure JavaScript Actions for Radio Buttons and Checkboxes
Script Placement: While 'Mouse Up' is the most common trigger for user clicks, you can also place these scripts in the 'Validate' action of the fields if you need the data to be formatted or verified before submission.
Edit PDF Forms Easily

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. 1. Open your PDF: Launch WPS Office and open your PDF document using the built-in PDF editor.
  2. 2. Access form tools: Navigate to the 'Form' tab on the top ribbon to view the available interactive form controls.
  3. 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. 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.
Easily add interactive form fields like text boxes, checkboxes, and radio buttons without complex setups.Fully compatible with standard PDF formats and standard Adobe Acrobat form properties.Lightweight software with an intuitive interface, making form creation accessible for beginners.
QA img-9

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.