PDF Editing Issues

How to Count X Marks or Selected Checkboxes in a PDF Form

Olivia MillerOlivia Miller Nov 5, 2026 870 views

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.

How to Count X Marks or Selected Checkboxes in a PDF Form
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.
Before you start

Ensure your PDF editor supports JavaScript for forms, as custom calculation scripts are required to tally the fields dynamically.

Solution 1Recommended

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.

1
Configure Checkbox Properties

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.

2
Create the Total Field

Add a Text Field to your form where the final count will be displayed. Right-click this field and select Properties.

3
Enable Custom Calculation

Navigate to the "Calculate" tab in the Text Field properties, select "Custom calculation script", and click the "Edit" button.

4
Insert the JavaScript

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;`

Use Checkboxes with a Custom Calculation Script
Naming Convention: Make sure the field names in your script array exactly match the names of the checkboxes on your PDF form.
Easily Edit PDF Forms

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. 1. Open your PDF: Launch WPS Office and open the PDF form you need to edit or fill.
  2. 2. Access Form Tools: Navigate to the "Form" tab on the top ribbon to access interactive form-building tools.
  3. 3. Insert Elements: Use the "Check Box" or "Text Field" tools to insert fillable areas exactly where you need them.
  4. 4. Save and Share: Save the edited PDF form to your local drive or cloud to easily collect and distribute data.
Easily fill, edit, and create interactive PDF forms.Highly compatible with Adobe Acrobat PDF formats.Lightweight software with an intuitive UI for quick document processing.Supports adding checkboxes, text fields, and signatures to your PDFs.
microsoft office alternative - wps office

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".