How to Count Selected Checkboxes in a PDF Form
Question details
The user needs a method to count the number of selected checkbox fields in a PDF form and display that total in a calculated text field.

- Product
- Adobe Acrobat / PDF
- Device & OS
- not provided
- Scenario
- Creating or editing a fillable PDF form that requires tallying selected options to show a final score or count.
- Observed behavior
- Needs a custom calculation script to iterate through specific checkboxes, determine if they are checked based on their export values, and output the total count.
Ensure you have a list of the exact field names of your checkboxes and know their configured export values (e.g., 'Yes', 'On') before applying the calculation script.
Use a Custom Calculation Script to Tally Checkboxes
Applying a JavaScript snippet within a text field's properties allows you to automatically calculate and display the total number of checked boxes.
This method requires adding a custom calculation script to the text field where you want the total count to appear. The script will check the state of specific checkboxes and increment the total if they are currently selected.
Open your PDF form in Edit mode, right-click the target text field where the total count should appear, and select 'Properties'.
Go to the 'Calculate' tab and select the 'Custom calculation script' option at the bottom.
Click 'Edit' and enter a JavaScript snippet that defines an array of your checkbox field names, loops through them using a 'for' loop, and increments a counter variable if the field's current value matches its selected export value.
Click 'OK' to save the script, close the properties dialog, and test the form by checking and unchecking the target boxes to ensure the text field updates automatically.
Edit and Manage PDF Forms Easily with WPS PDF
WPS Office provides a comprehensive PDF editor that allows you to view, fill, edit, and manage PDF forms effortlessly. Whether you are dealing with checkboxes, text fields, or signatures, WPS PDF makes it simple and efficient.
- 1. Open WPS PDF: Launch WPS Office and open your PDF document containing the fillable form.
- 2. Access Form Tools: Navigate to the 'Form' tab to interact with fillable fields, checkboxes, and text boxes.
- 3. Fill and Save: Easily check the required boxes, fill in text fields, and save the completed form to your local device or cloud storage.

Frequently Asked Questions
Why is my calculation text field not updating when I click a checkbox?
This usually happens if the checkbox does not have the 'Commit selected value immediately' option checked in its Options properties. Ensure this is enabled so the text field calculates instantly upon clicking.
Do all checkboxes need the same export value for the script to work?
Not necessarily, but having the same export value (like 'Yes' or 'On') simplifies your calculation script, as you only need to check for a single matching condition when looping through the fields.
Can I use a simple sum function instead of a custom script?
The simple 'Sum' function built into PDF form properties works only for adding numerical values typed into text fields. It cannot directly read the checked state of a checkbox, which is why a custom JavaScript is required.




