How to Automatically Fill PDF Text Fields from Selected Check Boxes
Question details
The user wants to configure a PDF form so that selecting specific check boxes automatically places predefined codes or text into a calculated text field.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where users select options via check boxes, and a text field dynamically updates to reflect the corresponding values or clears if nothing is checked.
- Observed behavior
- A custom JavaScript is needed to test the state of each check box and assign values to the text field accordingly.
Ensure you are using a PDF editor that supports form field editing and JavaScript calculations. You will need the exact names of your check box fields and target text fields.
Use an Array Script for Multiple Check Boxes
Best for situations where users can select more than one check box, and you want all selected values to appear in the text field separated by commas.
This approach involves setting an export value for each check box and using an array-based calculation script on the text field to gather all active values.
Right-click each check box and go to 'Properties'. Under the 'Options' tab, enter the code or text you want to appear in the 'Export Value' box.
Right-click the destination text field, select 'Properties', and navigate to the 'Calculate' tab.
Choose 'Custom calculation script' and enter the script: var result = []; if (this.getField("Check Box A").value != "Off") result.push("CODE-A"); if (this.getField("Check Box B").value != "Off") result.push("CODE-B"); event.value = result.join(", ");
Replace "Check Box A", "Check Box B", and "CODE" strings in the script with the actual field names and export values used in your PDF document.

Use an If/Else Script for Mutually Exclusive Options
Ideal when only one check box value should be displayed in the text field at a time, or prioritized in a specific order.
Use a MouseUp Event on Check Boxes
An alternative trigger method that applies the script directly to the check box instead of calculating the text field constantly.
Easily Manage Interactive PDF Forms with WPS Office
WPS Office features a robust PDF editor that simplifies creating, editing, and filling interactive PDF forms. Whether you need to insert check boxes, manage text fields, or secure your document, WPS Office offers an intuitive interface without the steep learning curve.
- 1. Open your PDF: Launch WPS Office and open your PDF document.
- 2. Access form tools: Navigate to the 'Form' tab on the top ribbon to reveal interactive elements.
- 3. Insert check boxes: Click the 'Check Box' tool and click anywhere on the page to place it.
- 4. Edit properties: Double-click the newly created field to adjust its appearance and export values.

Frequently Asked Questions
Why isn't my text field updating when I click the check box?
This usually happens if JavaScript is disabled in your PDF viewer's preferences. It can also occur if the field names in your script do not exactly match the actual names of your check boxes and text fields (field names are case-sensitive).
How do I set the export value of a check box?
In form editing mode, right-click the check box and select Properties. Go to the Options tab, and you will see a field labeled 'Export Value'. Type your desired code or text here.
Can I combine multiple check box values into a single text field?
Yes. By using a custom calculation script with an array (e.g., var result = []), you can push the export value of each selected box into the array, and then use result.join(', ') to display them together in one text field.




