How to Update a PDF Text Field When a Checkbox is Checked
Question details
The user needs to automatically change the displayed value of a PDF text field based on whether a specific checkbox is selected or cleared.

- Product
- Device & OS
- not provided
- Scenario
- Designing an interactive PDF form where a text field's value dynamically responds to checkbox interactions.
- Observed behavior
- The text field needs to instantly update with a specific numerical or text value upon checking or unchecking the box, without requiring the user to manually click into the text field.
Ensure you have a PDF editor that supports form field properties and custom JavaScript actions, and verify the exact names of your target text field and checkbox before proceeding.
Use a Custom JavaScript Action on the Checkbox
Add a Mouse Up JavaScript action to the checkbox properties to instantly capture its state and write the corresponding value to the target text field.
This method utilizes Acrobat JavaScript to check the event value of the checkbox. By attaching the script to the Mouse Up event, the text field updates immediately as soon as the user releases their mouse click.
Enter form editing mode in your PDF software, right-click the target checkbox, and select 'Properties' from the context menu.
In the Properties dialog box, go to the 'Actions' tab. Select 'Mouse Up' from the Select Trigger dropdown menu.
Choose 'Run a JavaScript' from the Select Action dropdown menu, and click the 'Add' button to open the JavaScript Editor.
Type the following code: var value = event.target.value; var result = value === "Yes" ? 19.75 : 0.00; this.getField("Member Discount").value = result; (Replace "Yes" with your checkbox's export value, 19.75 with your desired checked value, and "Member Discount" with your actual text field name).
Click 'OK' to close the editor, then close the Properties window. Preview your form and click the checkbox to verify that the text field updates automatically.

Create and Edit Dynamic PDF Forms with WPS Office
WPS Office features a robust PDF editor that allows you to easily insert checkboxes, manage text fields, and handle document properties. It is an excellent tool for creating interactive and professional PDF forms.
- 1. Open the PDF Document: Launch WPS Office and open your existing PDF form or create a new blank PDF.
- 2. Access Form Controls: Navigate to the 'Form' tab on the top ribbon to reveal the interactive form field tools.
- 3. Insert Form Fields: Click on the 'Checkbox' or 'Text Field' icons to place new elements onto your document.
- 4. Edit Field Properties: Double-click any inserted form field to open its properties, where you can configure names, export values, and appearance.

Frequently Asked Questions
Why is the text field not updating when I click the checkbox?
This usually happens if the JavaScript is attached to the wrong trigger or contains a typo. Ensure the script is set to the 'Mouse Up' action and that the exact name of the text field perfectly matches the string inside this.getField().
What is the default export value of a PDF checkbox?
In most PDF editors, the default export value for a checked box is 'Yes', and the unchecked state is 'Off'. You can customize the checked export value in the checkbox properties under the Options tab.
Can I update multiple text fields using the same checkbox?
Yes. You can expand your JavaScript code within the same Mouse Up action to target multiple fields. Simply add additional lines like this.getField("FieldTwo").value = someValue; below your existing code.




