How to Calculate PDF Form Field Values from Multiple Checkboxes
Question details
The user wants to dynamically set a text field's value based on which checkboxes are selected in a PDF form, including specific values for individual selections and unique values for combinations of checkboxes.

- Product
- Adobe Acrobat PDF Forms
- Device & OS
- not provided
- Scenario
- Setting up form field calculations to display custom numeric totals in a text field depending on the user's checkbox choices.
- Observed behavior
- When using JavaScript, single-checkbox conditions are evaluated before combination conditions, causing the script to output the single-checkbox value instead of the expected combination value.
Ensure you are in the 'Prepare Form' editing mode and have correctly named each of your checkbox fields and your target text field before applying calculation scripts.
Use Custom JavaScript for Checkbox Combinations
This is the recommended approach when you need specific results for combinations of checkboxes (e.g., selecting Checkbox 1 and Checkbox 2 produces a unique value).
When writing conditional logic for multiple checkboxes, order is critical. You must test the most specific conditions (such as all checkboxes checked) first. If you test individual checkboxes first, the code will execute that condition and ignore the combinations entirely.
Right-click the target text field where you want the result to be displayed and select 'Properties'.
Navigate to the 'Calculate' tab at the top of the Properties window and choose 'Custom calculation script'.
Click the 'Edit' button to open the JavaScript editor.
Enter your if/else statements, evaluating combinations first. For example: `if (this.getField("CB1").value !== "Off" && this.getField("CB2").value !== "Off") { event.value = 3; } else if (this.getField("CB1").value !== "Off") { event.value = 1; } else { event.value = 0; }`

Use the Built-In SUM Function for Independent Values
Best used when each checkbox has an independent numeric value and you simply want to add them together without complex combinations.
Create and Manage Interactive PDF Forms Easily with WPS Office
WPS Office provides a comprehensive PDF toolkit that allows you to effortlessly insert checkboxes, text fields, and apply calculation logic without a steep learning curve.
- 1. Open Your PDF: Launch WPS Office and open your PDF form document.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to easily insert checkboxes and text fields.
- 3. Set Properties: Double-click any text field to access its properties and configure standard calculations or custom scripts.

Frequently Asked Questions
Why does my text field calculate the wrong value when I select multiple checkboxes?
This usually happens because your calculation script checks for single checkboxes before combinations. JavaScript executes sequentially and stops at the first true condition. To fix this, always place the most complex combination conditions at the top of your if/else statement.
How do I assign a specific numeric value to a PDF checkbox?
In Prepare Form mode, right-click the checkbox, select Properties, and navigate to the Options tab. Look for the 'Export Value' field and enter your desired numeric value.
Can I calculate the sum of checkboxes without writing JavaScript?
Yes. If your checkboxes have independent numeric export values, you can use the built-in calculation tool. Go to the Calculate tab of your text field, select 'Value is the sum (+) of the following fields', and pick the checkboxes you want to add together.




