How to Count X Marks or Selected Checkboxes in a PDF Form
Question details
The user needs a method to dynamically count how many fields within a specific group in a fillable PDF form contain an "X" or are checked.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Designing a fillable PDF form that requires an automated tally of selected options or specific text inputs.
- Observed behavior
- A calculation script is required to tally the number of checkboxes displaying an X (or text fields containing the letter X) and output the total count into a designated field.
Ensure your PDF editor supports JavaScript for forms, as custom calculation scripts are required to tally the fields dynamically.
Use Checkboxes with a Custom Calculation Script
Checkboxes are the most reliable way to tally user selections. You can set their appearance to a cross ("X") and use JavaScript to count the checked boxes.
Using checkboxes restricts the user input to a simple on/off state, preventing errors caused by typos or varying character cases in text fields. The selected state of a checkbox is usually reported as "Yes" in PDF form scripts.
Create your checkboxes, right-click to open their Properties, and go to the "Options" tab. Change the Check Box Style to "Cross" so they display an X when clicked.
Add a Text Field to your form where the final count will be displayed. Right-click this field and select Properties.
Navigate to the "Calculate" tab in the Text Field properties, select "Custom calculation script", and click the "Edit" button.
Enter a script that loops through your checkbox names and counts the "Yes" values. For example: `var fields = ["Check Box1", "Check Box2"]; var count = 0; for (var i = 0; i < fields.length; i++) { var f = this.getField(fields[i]); if (f != null && f.value == "Yes") count++; } event.value = count;`

Count "X" Marks in Text Fields
If your form strictly relies on users typing an "X" into text fields rather than clicking checkboxes, you can adjust the script to validate that specific character.
Edit and Fill PDF Forms with WPS Office
WPS PDF provides comprehensive tools for reading, editing, and filling out PDF forms effortlessly, serving as an excellent and lightweight solution for your document management needs.
- 1. Open your PDF: Launch WPS Office and open the PDF form you need to edit or fill.
- 2. Access Form Tools: Navigate to the "Form" tab on the top ribbon to access interactive form-building tools.
- 3. Insert Elements: Use the "Check Box" or "Text Field" tools to insert fillable areas exactly where you need them.
- 4. Save and Share: Save the edited PDF form to your local drive or cloud to easily collect and distribute data.

Frequently Asked Questions
Can I calculate the total value of checked boxes instead of just counting them?
Yes. Instead of simply incrementing a counter by 1, you can set an export value for each checkbox and modify your custom calculation script to extract and sum those export values.
Why isn't my checkbox calculation script updating the total?
Ensure the exact names of your checkboxes match the array list in your JavaScript code. Also, verify that the export value for the checked state is set to "Yes" (the default) and that JavaScript is enabled in your PDF editor's preferences.
Are checkboxes better than text fields for tracking selections?
Yes, checkboxes are much more reliable because they standardize user input. With text fields, users might type a lowercase "x", add unnecessary spaces, or use entirely different characters, which complicates the script's validation process.
How do I make the checkbox look like an "X" instead of a checkmark?
Right-click the checkbox, select Properties, and navigate to the Options tab. Change the "Check Box Style" dropdown from the default checkmark to "Cross".




