How to Set a PDF Text Field Value from Checkbox Selections
Question details
The user needs a text field in a PDF form to automatically display a specific value or calculated score based on which checkboxes are selected.

- Product
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form that involves automated scoring, where checkbox selections dictate the numeric value displayed in a designated score text field.
- Observed behavior
- The text field requires a custom calculation script to dynamically listen to the checkbox states and update its own value accordingly.
Ensure your PDF editing software supports JavaScript for forms, and double-check the exact field names of your checkboxes before applying any custom scripts.
Use Grouped Checkboxes with a Custom Script
Best for scenarios where only one checkbox from a group is selected, passing its specific export value to the text field.
By giving multiple checkboxes the identical field name but different export values, they act as a mutually exclusive group. You can then use a simple script in your text field to display the chosen value.
Open your PDF form editor, double-click each checkbox to open its Properties, and set the 'Name' field to be exactly the same for all (e.g., 'Check Box'). In the Options tab, give each one a unique Export Value.
Double-click the 'Score' text field, navigate to the Calculate tab, and select 'Custom calculation script'.
Enter the following code: if (this.getField("Check Box").value != "Off") event.value = this.getField("Check Box").value; else event.value = "";
Save your changes, exit form editing mode, and click the checkboxes to verify that the text field updates automatically.

Use a Loop to Calculate a Total Score from Multiple Checkboxes
Ideal for tests or assessments where users can select multiple boxes, and each checked box adds a set number of points to the final score.
Easily Create and Edit PDF Forms with WPS Office
WPS Office provides a comprehensive suite of PDF tools, allowing you to easily insert text fields, checkboxes, and interactive elements to build professional forms.
- 1. Open PDF in WPS Office: Launch WPS Office and open your PDF document.
- 2. Navigate to the Form Tab: Click on the 'Form' tab in the top ribbon to access the interactive form controls.
- 3. Insert Form Elements: Click 'Check Box' or 'Text Field' and draw them directly onto your document where needed.
- 4. Edit Properties: Double-click the inserted fields to rename them, set default values, or adjust formatting to complete your form.

Frequently Asked Questions
Why is my PDF text field not updating when I click a checkbox?
This usually happens if the form field names in your JavaScript do not exactly match the actual names of the checkboxes, or if your PDF viewer does not have JavaScript enabled. Double-check spelling and capitalization.
What does the "Off" value mean in PDF checkbox scripts?
In standard PDF forms, an unchecked checkbox typically returns an export value of "Off". Checking for this specific string in your script allows the code to easily determine whether a user has selected the box.
Can I assign different point values to different checkboxes?
Yes. Instead of simply counting the boxes, you can assign unique export values (like '10', '15', '20') to each checkbox in their Properties. You would then write a script that adds these specific field values together when they are not 'Off'.
Do these custom calculation scripts work on mobile PDF readers?
Not consistently. While these scripts work perfectly on robust desktop PDF readers, many basic mobile PDF viewers do not fully support JavaScript execution. For forms intended for mobile users, standard uncalculated fields might be more reliable.




