PDF Editing Issues

How to Count 'Yes' Answers in Adobe PDF Forms | PDF Form Calculation

John WilsonJohn Wilson Oct 28, 2026 868 views

Question details

The user needs a calculated field in a PDF form to automatically display the total number of 'Yes' responses from a specific set of Yes/No questions.

How to Count 'Yes' Answers in an Adobe PDF Form
Product
Adobe Acrobat / PDF Forms
Device & OS
not provided
Scenario
Creating interactive PDF forms, such as surveys, quizzes, or checklists, where tallying specific responses is required.
Observed behavior
The total count of 'Yes' responses needs to be automatically calculated and displayed in a designated form field.
Before you start

Ensure you have access to a PDF editor that supports JavaScript custom calculations, such as Adobe Acrobat Pro, and verify the exact names of your Yes/No form fields before writing the script.

Solution 1Recommended

Use a Custom Calculation Script to Count Responses

Apply a short JavaScript code snippet to a text field's calculation properties to automatically tally the 'Yes' answers.

This method uses JavaScript to loop through a sequence of form fields (e.g., Question11 to Question15). It checks each field's value and increments the total count if the value equals 'Yes'.

For this script to work perfectly, your Yes/No fields must have a consistent naming convention, such as a static prefix followed by a sequential number.

1
Enter Prepare Form Mode

Open your PDF form in Adobe Acrobat Pro and select the 'Prepare Form' tool from the right-hand pane.

2
Access Field Properties

Right-click the text field where you want the total count to appear (e.g., Section1YesCount) and select 'Properties'.

3
Set Up Custom Calculation

Go to the 'Calculate' tab, select the 'Custom calculation script' option, and click the 'Edit' button.

4
Insert the JavaScript Code

Paste the following code into the editor: var total = 0; for (var i = 11; i <= 15; i++) { var f = this.getField('Question' + i); if (f && f.valueAsString == 'Yes') total++; } event.value = total;

5
Adjust and Save

Modify the field prefix ('Question') and the number range (11 to 15) in the script to match your actual field names. Click 'OK', close the properties window, and test your form.

Use a Custom Calculation Script to Count Responses
Field Naming Note: If your fields use a leading zero (e.g., ANSWER01 to ANSWER30), you will need to adjust the script to add the leading zero for numbers under 10 using a ternary operator.
Comprehensive PDF Editor

Create, Edit, and Fill PDF Forms Easily with WPS Office

WPS Office provides a comprehensive PDF editor that allows you to easily view, fill out interactive forms, and manage your PDF documents without the need for expensive software.

  1. 1. Open PDF in WPS: Launch WPS Office and open your interactive PDF form.
  2. 2. Fill the Form: Click on the form fields to select your 'Yes' or 'No' answers or input text.
  3. 3. Save and Export: Save your filled form or export it to other formats if needed.
Free and lightweight PDF reader and editorSeamlessly fill out interactive PDF forms and checklistsHigh compatibility with standard Adobe PDF formatsConvert PDFs to Word, Excel, and PowerPoint effortlessly
microsoft office alternative - wps office

Frequently Asked Questions

Why is my calculation script not updating the total?

Ensure that the calculation order is correct if you have multiple calculated fields. Also, check that your field names exactly match the prefix and numbers defined in the JavaScript code, including case sensitivity.

Can I count 'No' answers instead of 'Yes'?

Yes. You can simply change the condition in the script from f.valueAsString == 'Yes' to f.valueAsString == 'No' to tally the 'No' responses.

How do I handle field names with leading zeros, like Question01 to Question15?

You need to modify your loop to format the number correctly. For example, use a ternary operator like var fname = 'Question' + ((i < 10) ? '0' + i : i); to generate the correct field name string before calling this.getField(fname).