How to Enable or Disable PDF Form Checkboxes Based on Another Checkbox
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.

- 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.
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.
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.
Open your PDF in form editing mode, right-click the controlling checkbox, and select 'Properties'.
In the Properties dialog box, click on the 'Actions' tab. Select 'Mouse Up' from the 'Select Trigger' dropdown menu.
From the 'Select Action' dropdown, choose 'Run a JavaScript' and click the 'Add' button to open the JavaScript Editor.
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;.
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.

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. Open your PDF file: Launch WPS Office and open your interactive PDF form document.
- 2. Access PDF tools: Navigate to the 'PDF' tab on the top ribbon to view available reading and filling tools.
- 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. Save your filled form: Once completed, click 'Save' to retain your inputted data safely within the PDF format.

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.




