How to Sum Acrobat Checkbox Export Values with JavaScript
Question details
The user needs to calculate the total sum of the actual export values of selected radio-style checkboxes in a PDF form, rather than simply counting the total number of checked boxes.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating or editing an interactive PDF form where checkboxes hold specific numeric export values (e.g., 1, 3, 5) that need to be dynamically added into a total field.
- Observed behavior
- The current calculation is counting the number of selections made instead of extracting and adding the specific export values assigned to those selected checkboxes.
Verify that every checkbox in your PDF form has the correct numeric 'Export Value' assigned in its Properties > Options tab before applying any calculation scripts.
Calculate Sum Using Custom JavaScript
Use this method to write a custom script that specifically checks the valueAsString of each checkbox and adds the numeric export value to the total.
When using grouped radio-style checkboxes, Acrobat's default summation might behave unexpectedly by incrementing standard counts. By using a custom JavaScript calculation, you force the form to evaluate the specific export string assigned to the selected box.
Launch Adobe Acrobat, open your PDF document, and select 'Prepare Form' from the Tools pane.
Right-click the text field where you want the final sum to appear and select 'Properties'.
In the Properties dialog box, click on the 'Calculate' tab.
Select the 'Custom calculation script' radio button and click 'Edit'. Enter a script that evaluates the export value of the checkbox. For example, test the field's valueAsString against your export values. If the selected value is '3', the script should parse it as a number and add 3 to the total variable. Click OK when done.

Use the Built-in Sum Function
For straightforward checkbox calculations, Acrobat's native Calculate tab can automatically pull export values if they are set correctly.
Create and Calculate PDF Forms Easily with WPS Office
WPS Office provides a comprehensive PDF editor that allows you to intuitively create interactive forms, add checkboxes with custom export values, and set up automatic field calculations without needing complex JavaScript coding.
- 1. Open WPS Office PDF Editor: Launch WPS Office and open your PDF document using the PDF module.
- 2. Insert Form Fields: Navigate to the 'Form' tab on the top ribbon and insert checkboxes and text fields into your document.
- 3. Configure Properties: Double-click a field to open its properties. Here you can easily assign export values to checkboxes and configure sum calculations for text fields.

Frequently Asked Questions
Why does my PDF form count the number of checkboxes instead of adding their values?
This usually happens when the checkboxes do not have a specific numerical 'Export Value' assigned in their properties, or the calculation method is defaulting to counting instances rather than summing the string values. You must manually define these values in the Options tab.
How do I set an export value for a checkbox in Adobe Acrobat?
Enter the 'Prepare Form' mode, right-click the checkbox, and select Properties. Navigate to the Options tab, and type your desired numerical value into the 'Export Value' box.
Can I calculate PDF form fields without writing JavaScript?
Yes, for simple mathematical operations like addition or multiplication, you can use the built-in Calculate tab within the text field properties. Just select 'Value is the sum (+)' and pick the target form fields.




