PDF Editing Issues

How to Enable or Disable PDF Form Checkboxes Based on Another Checkbox

Kushani NimanthikaKushani Nimanthika Oct 28, 2026 869 views

Question details

The user wants to set up conditional logic in a PDF form where checking one master checkbox automatically makes other checkboxes read-only, and unchecking it enables them.

How to Enable or Disable PDF Form Checkboxes Based on Another Checkbox
Product
PDF Form Editor
Device & OS
not provided
Scenario
Designing an interactive PDF form that requires dynamic field restrictions based on user selections.
Observed behavior
Certain checkbox fields need to automatically toggle their read-only property depending on whether a specific controlling checkbox is selected or cleared.
Before you start

Ensure you are using a PDF editing software that supports JavaScript for form fields, and write down the exact field names of the checkboxes you intend to control.

Solution 1Recommended

Use a Mouse Up JavaScript Action on the Controlling Checkbox

Apply a custom JavaScript snippet to the controlling checkbox so that its state triggers a change in the 'readonly' property of your target checkboxes.

In PDF forms, you can use JavaScript to create dependencies between fields. By attaching a script to the 'Mouse Up' event of the master checkbox, the script will run every time the user clicks it.

The logic checks if the master checkbox is 'Off' (unselected). If it is unselected, the target checkboxes become active. If selected, the target checkboxes become read-only.

1
Access the controlling checkbox properties

Open your PDF in form editing mode, right-click the controlling checkbox, and select 'Properties'.

2
Navigate to the Actions tab

In the Properties dialog box, click on the 'Actions' tab. Select 'Mouse Up' from the 'Select Trigger' dropdown menu.

3
Add a JavaScript action

From the 'Select Action' dropdown, choose 'Run a JavaScript' and click the 'Add' button to open the JavaScript Editor.

4
Enter the conditional script

Paste the following code into the editor: var state = event.target.value == "Off"; getField("cb1").readonly = !state; getField("cb2").readonly = !state; getField("cb3").readonly = !state; getField("cb4").readonly = !state;.

5
Save and test the form

Click 'OK' to close the editor, then close the Properties dialog. Preview your PDF and click the controlling checkbox to verify that the target fields lock and unlock properly.

Use a Mouse Up JavaScript Action on the Controlling Checkbox
Match Field Names Exactly: In the script provided, you must replace 'cb1', 'cb2', 'cb3', and 'cb4' with the actual field names of your target checkboxes. Remember that field names in JavaScript are case-sensitive.
Efficient PDF Form Management

Manage and Fill Interactive PDFs with WPS Office

WPS Office provides a highly compatible, lightweight PDF toolkit that allows you to seamlessly view, fill, and manage complex interactive PDF forms, ensuring embedded JavaScript elements trigger correctly.

  1. 1. Open your PDF file: Launch WPS Office and open your interactive PDF form document.
  2. 2. Access PDF tools: Navigate to the 'PDF' tab on the top ribbon to view available reading and filling tools.
  3. 3. Fill the interactive form: Click directly on the checkboxes or text fields. WPS Office will process embedded form rules and logic as you input your data.
  4. 4. Save your filled form: Once completed, click 'Save' to retain your inputted data safely within the PDF format.
Smoothly fill out interactive PDF forms with checkboxes and dropdownsExcellent compatibility with standard PDF formats and scriptsLightweight architecture for fast document loading and renderingEasily edit, merge, split, and convert PDF documents
microsoft office alternative - wps office

Frequently Asked Questions

Why is my JavaScript code not affecting the target checkboxes?

This usually happens if the field names in your script do not exactly match the field names in the form's properties. Check for typos, spaces, and ensure the capitalization is identical, as JavaScript is strictly case-sensitive.

Can I automatically uncheck the target fields when they become read-only?

Yes. You can add lines like getField("cb1").value = "Off"; inside an 'if' statement in your script. This ensures that when the controlling checkbox is selected, the target fields are cleared before being locked.

Will these conditional checkboxes work in any PDF viewer?

No, interactive features that rely on JavaScript require a full-featured PDF reader. Basic browser-based PDF viewers or simple mobile readers may ignore the scripts, meaning the conditional logic will not function.

Is it possible to use this logic for text fields instead of checkboxes?

Absolutely. You can apply the same readonly property logic to text fields, dropdowns, or radio buttons by referencing their exact field names in the getField() function.