How to Display a Text Field Value Based on a Checkbox in PDFs
Question details
The user needs to dynamically display the name of a selected checkbox option in a designated text field elsewhere in the PDF document.

- Product
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where text fields auto-populate based on a user's checkbox selections (e.g., selecting an 'apples' checkbox displays 'apples' in a text field).
- Observed behavior
- The user wants to link a checkbox selection to a text field so that checking the box runs an action to output a specific text string on another page.
Ensure you have a PDF editor that supports interactive form fields and JavaScript, and identify the exact field names of your target checkboxes and text fields.
Use JavaScript on the Checkbox Mouse Up Action
Assign a custom JavaScript action to the checkbox's Mouse Up event to automatically push the chosen value to the text field.
To make a text field dynamically mirror a checkbox choice, you must assign an export value to the checkbox and use a short script to detect when the box is checked or unchecked. If the box is checked, the script outputs your desired word; if unchecked, it clears the text field.
Open your PDF form in edit mode. Right-click the checkbox you want to configure, select 'Properties', and navigate to the 'Options' tab. Set the 'Export Value' to the word you want displayed (e.g., 'Oranges').
Switch to the 'Actions' tab in the Properties window. Select 'Mouse Up' as the trigger, choose 'Run a JavaScript' from the action dropdown menu, and click 'Add'.
In the JavaScript editor, enter the following code: this.getField("Text field").value = event.target.value == "Off" ? "" : "Oranges";
Replace 'Text field' with the exact name of your target text field, and 'Oranges' with your desired output. Click 'OK' to save, exit form editing mode, and click the checkbox to test the result.
Create and Edit Advanced PDF Forms Easily in WPS Office
WPS Office provides a comprehensive suite of PDF tools, allowing you to insert interactive form fields like checkboxes and text boxes, and edit their properties with ease.
- 1. Open your PDF: Launch WPS Office and open the PDF document you want to edit.
- 2. Access Form Controls: Navigate to the 'Form' tab on the top ribbon to access the interactive form controls.
- 3. Insert Form Fields: Select the Checkbox or Text Field tool to draw and add new interactive elements to your document.
- 4. Edit Properties: Double-click the newly inserted form fields to modify their properties, field names, and export values.

Frequently Asked Questions
Can I use the same name for multiple checkboxes?
Yes, giving multiple checkboxes the same name groups them together like radio buttons. However, you must ensure each has a unique export value so the form recognizes which specific option was selected.
Why isn't my text field updating when I click the checkbox?
Ensure that the JavaScript action is set to trigger on 'Mouse Up' rather than 'Mouse Down'. Additionally, verify that the exact name of the target text field matches the field name referenced in your script, as JavaScript is case-sensitive.
How do I clear the text field when the checkbox is unchecked?
The provided script automatically handles this using a conditional statement (event.target.value == 'Off' ? '' : 'Your Value'). When the box is unchecked, its value evaluates to 'Off', which pushes an empty string to clear the text field.




