How to Use One Checkbox to Select and Lock Multiple Checkboxes in PDF
Question details
The user needs to create a master checkbox in a PDF that selects multiple individual checkboxes and makes them read-only when checked, and unchecks and makes them editable again when cleared.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating advanced interactive PDF forms where certain options depend on a primary master selection.
- Observed behavior
- Requires a method to programmatically control the checked state and read-only status of multiple target checkboxes from a single master checkbox.
Ensure your PDF editor supports JavaScript for form fields, as this interaction requires adding a custom script to the checkbox properties.
Add a JavaScript Action to the Master Checkbox
Use a custom JavaScript triggered by a 'Mouse Up' action to control the value and read-only state of target checkboxes.
By applying a small snippet of JavaScript to the master checkbox, you can dynamically update the properties of other form fields when the user interacts with it.
Open form editing mode in your PDF editor, right-click the master checkbox, and select 'Properties'.
Navigate to the 'Actions' tab, select 'Mouse Up' from the Select Trigger dropdown, and choose 'Run a JavaScript' from the Select Action dropdown.
Click 'Add' and enter the script to modify the target field. For example: getField("CheckBox1").readonly = true; to lock it. You will need to wrap this in an if/else statement based on the master checkbox state to toggle it on and off.
Save your script, exit form editing mode, and click the master checkbox to ensure it correctly selects and locks the individual checkboxes.

Use Hierarchical Naming for Checkbox Groups
Simplify your JavaScript code by naming related checkboxes hierarchically, allowing you to lock the entire group at once.
Create and Manage Interactive PDF Forms with WPS Office
WPS Office provides comprehensive PDF editing tools, allowing you to easily add, manage, and configure form fields, checkboxes, and interactive elements with ease.
- 1. Open the PDF: Launch WPS Office and open your PDF document.
- 2. Access form tools: Navigate to the 'Form' tab in the top ribbon to reveal all interactive form controls.
- 3. Insert checkboxes: Select 'Check Box' and click on the document area where you want to place your form controls.
- 4. Edit properties: Double-click the inserted checkbox to modify its properties, set export values, and configure custom actions.

Frequently Asked Questions
Why isn't my JavaScript action working on the PDF checkbox?
Ensure you have selected 'Mouse Up' as the trigger. If you use 'Mouse Down', the script runs before the checkbox state actually changes. Additionally, check that the field names in your script perfectly match the actual names of your checkboxes, as they are case-sensitive.
Can I make text fields read-only using the same JavaScript method?
Yes, the exact same JavaScript property (getField("FieldName").readonly = true;) applies to text fields, dropdown menus, and other form controls within a PDF document.
Will this master checkbox feature work if users open the PDF in a web browser?
Many built-in web browser PDF viewers have limited or no support for JavaScript. For interactive forms with custom scripts to work reliably, advise users to open the document in a dedicated PDF application like WPS Office or Adobe Acrobat.




