How to Count Yes or No Responses in a PDF Form
Question details
The user needs to count the total number of "Yes" or "No" responses from multiple fields within a PDF form and display this combined tally dynamically in a separate calculated result field.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating or editing an interactive PDF form where user responses need to be automatically tallied to show the total number of specific string responses, such as "No".
- Observed behavior
- Standard predefined PDF calculation functions do not inherently count specific text strings. An automated counting mechanism utilizing a custom script is required to tally specific field values.
Ensure you have the exact field names for all the "Yes" or "No" response fields in your PDF form. You will need access to the Prepare Form tool in your PDF editor to add custom JavaScript.
Use a Custom Calculation Script in the Result Field
Add a custom JavaScript loop to a result text field that checks each target response field and increments a counter if the value matches "Yes" or "No".
Standard PDF calculations (like sum or average) only work with numerical values. To count specific text responses or checkbox states, you must write a custom JavaScript snippet that evaluates each field's value independently.
Open your PDF document in Adobe Acrobat or your advanced PDF editor and select the "Prepare Form" tool from the right pane.
Right-click the text field where you want the total count to appear (your calculated field) and select "Properties" from the context menu.
Navigate to the "Calculate" tab, select the "Custom calculation script" radio button, and click the "Edit" button.
Write a JavaScript snippet that defines a counter, checks your specific response fields, and adds to the counter. Assign the final count to the event value. Example: var count = 0; if (this.getField('Response1').valueAsString == 'No') count++; if (this.getField('Response2').valueAsString == 'No') count++; event.value = count;
Click "OK" to close the JavaScript editor, then close the Properties window. Exit the "Prepare Form" mode to test your fields and verify the tally updates correctly.

Easily Manage and Fill PDF Forms with WPS Office
WPS Office provides a comprehensive, lightweight PDF editor that allows you to easily view, fill out, and manage interactive PDF forms. It serves as a powerful alternative for handling complex PDF workflows and everyday document tasks.
- 1. Open WPS Office: Launch the WPS Office application on your computer and navigate to the "PDF" tab on the main dashboard.
- 2. Load Your PDF Form: Click "Open PDF" and browse your files to select the interactive PDF form you need to manage or fill out.
- 3. Fill the Responses: Click on any fillable text field or checkbox to enter your "Yes" or "No" responses. The form will behave smoothly, processing simple calculations natively.
- 4. Save and Export: Once completed, click the "Save" icon or use the "Export to PDF" feature to finalize your document for sharing.

Frequently Asked Questions
Can I count checkboxes instead of text fields?
Yes. Checkboxes export a specific value when checked (often "Yes", "On", or a custom export value). You can use a similar JavaScript to check if `this.getField("CheckboxName").value !== "Off"` and increment your counter accordingly.
Why is my calculation script not updating immediately?
PDF form calculations rely on a specific field calculation order. If your result field calculates before the response fields are finalized, the count may lag by one step. Check the field calculation order in your form settings to ensure the total is calculated last.
Does custom PDF JavaScript work on mobile PDF readers?
Custom JavaScript calculations in PDF forms are generally supported on full desktop versions of advanced PDF editors. Many mobile PDF viewers and web browsers have limited or no support for JavaScript, which may prevent the count from updating on those devices.




