PDF Editing Issues

How to Use an Acrobat JavaScript Button to Select a Checkbox in PDF Forms

Jason MillerJason Miller Nov 2, 2026 869 views

Question details

The user needs to configure a clickable button in a PDF form that uses JavaScript to automatically check a specific checkbox.

How to Select a Checkbox Using an Acrobat JavaScript Button
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.
Before you start

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.

Solution 1Recommended

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.

1
Enter form editing mode

Open your PDF document in your PDF editor and activate the 'Prepare Form' or form editing mode to reveal all interactive fields.

2
Access button properties

Right-click the button you want to configure, select 'Properties' from the context menu, and navigate to the 'Actions' tab.

3
Add a JavaScript action

In the 'Select Action' dropdown menu, choose 'Run a JavaScript'. Set the trigger to 'Mouse Up' (recommended for accessibility) and click the 'Add' button.

4
Input the JavaScript code

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.

Configure the Button with Acrobat JavaScript
Understanding Export Values: The value "Yes" is the default export value for a checked box in Acrobat forms. If you customized the export value of your checkbox in its properties, you must update the script to match that exact value.

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. 1. Open your PDF in WPS Office: Launch WPS Office and open the PDF form you wish to edit.
  2. 2. Access the Form tab: Navigate to the 'Form' tab on the top ribbon to view all interactive field tools available.
  3. 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. 4. Edit field properties: Double-click any inserted field to instantly configure its name, appearance, and required behaviors.
Fully compatible with standard PDF forms and interactive fieldsLightweight, fast, and user-friendly PDF reader and editorComprehensive tools for adding checkboxes, buttons, and text fields effortlesslySeamless integration with Word, Excel, and PowerPoint file formats
QA img-9

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.