How to Use an Acrobat JavaScript Button to Select a Checkbox in PDF Forms
Question details
The user needs to configure a clickable button in a PDF form that uses JavaScript to automatically check a specific checkbox.

- Product
- Adobe Acrobat / PDF Forms
- Device & OS
- not provided
- Scenario
- Designing an interactive PDF form where users need to click a button to perform actions, such as automatically checking a box before adding attachments.
- Observed behavior
- The goal is to program a button to change a checkbox's state using Acrobat-specific JavaScript, as standard web-based scripts like jQuery fail to execute in PDF environments.
Ensure you have a PDF editor that supports advanced interactive form field creation and JavaScript execution. Verify the exact field name of the target checkbox before applying the script.
Configure the Button with Acrobat JavaScript
Apply a specific Acrobat JavaScript code snippet to the button's mouse action event to trigger the checkbox state.
Standard web scripts (like jQuery) are designed for web browsers and will not work within PDF documents. Acrobat PDF forms use a specialized JavaScript API to interact with form fields.
Open your PDF document in your PDF editor and activate the 'Prepare Form' or form editing mode to reveal all interactive fields.
Right-click the button you want to configure, select 'Properties' from the context menu, and navigate to the 'Actions' tab.
In the 'Select Action' dropdown menu, choose 'Run a JavaScript'. Set the trigger to 'Mouse Up' (recommended for accessibility) and click the 'Add' button.
In the JavaScript Editor window, type: this.getField("Check Box2").value = "Yes";. Replace "Check Box2" with the exact name of your checkbox field. Click OK, then close the properties dialog to save.

Create and Manage PDF Forms Easily with WPS Office
WPS Office provides a powerful, intuitive PDF editor that allows you to effortlessly manage interactive form fields, edit text, and organize PDF pages without needing complicated scripting for basic tasks.
- 1. Open your PDF in WPS Office: Launch WPS Office and open the PDF form you wish to edit.
- 2. Access the Form tab: Navigate to the 'Form' tab on the top ribbon to view all interactive field tools available.
- 3. Insert form fields: Select the 'Check Box' or 'Push Button' tools, then click and drag on your document page to place them exactly where needed.
- 4. Edit field properties: Double-click any inserted field to instantly configure its name, appearance, and required behaviors.

Frequently Asked Questions
Why isn't my jQuery code working in the PDF form?
PDF documents use a highly specific Adobe Acrobat JavaScript API for form fields, which operates differently from web browser JavaScript. Standard web frameworks like jQuery or code copied from JSFiddle are unsupported and will not function inside a PDF.
How do I find the exact name of my checkbox field?
Enter your PDF editor's form editing mode, right-click the target checkbox, and select Properties. Look under the 'General' tab; the text in the 'Name' box is the exact identifier you must reference in your JavaScript.
How can I make the button uncheck the box instead?
To uncheck a box using Acrobat JavaScript, change the assigned value in your script to "Off". The code should look like this: this.getField("Check Box2").value = "Off";.
Can users manually clear the checkbox after clicking the button?
Yes. As long as the checkbox field is not marked as 'Read Only' in its properties, users can manually click the checkbox to clear it or check it again, regardless of the button's JavaScript action.




