How to Calculate a Pass or Fail Percentage in a PDF Form
Question details
The user wants to create an interactive PDF form that totals the values of multiple questions, calculates a percentage score, and displays either a Pass or Fail message based on the result.

- Product
- Adobe PDF Forms
- Device & OS
- not provided
- Scenario
- Creating a graded quiz or assessment in a PDF document where the final score is automatically calculated from user inputs.
- Observed behavior
- The goal is to implement an Acrobat JavaScript calculation using loops or simple addition to dynamically evaluate fields and output a percentage alongside a Pass/Fail string.
Ensure your form fields are named consistently (e.g., Answer1, Answer2, or A1A1, A1A2) so that your calculation script can easily reference them without errors.
Use a Loop-Based Custom JavaScript Calculation
Ideal for forms with many questions, using a JavaScript loop significantly reduces script length and automates field summation.
By applying a loop, the script systematically checks all question fields that follow a specific naming pattern. It totals the values, calculates the average based on the number of questions, and evaluates it against your passing threshold.
Right-click the target text field where you want the final percentage and Pass/Fail result to appear, then select 'Properties' from the context menu.
Go to the 'Calculate' tab in the Properties window, select the 'Custom calculation script' radio button, and click the 'Edit' button.
Paste your calculation code. For example: var numQuestions = 10; var total = 0; for (var i = 1; i <= numQuestions; i++) { var value = Number(this.getField('A1A' + i).valueAsString); if (isNaN(value)) value = 0; total += value; }
Add the result logic beneath the loop: var result = total / numQuestions; event.value = (result * 100) + '% ' + (result < 0.7 ? 'Fail' : 'Pass!'); Click 'OK' to save.

Use a Manual Addition Script for Fewer Questions
If your assessment form only contains two or three questions, manually referencing each field is a straightforward alternative to using a loop.
Edit and Manage PDF Forms with WPS Office
WPS Office offers a robust built-in PDF toolkit that lets you easily open, view, fill, and manage interactive PDF forms without needing heavy external applications.
- 1. Install WPS Office: Download and install the free version of WPS Office from the official website.
- 2. Open Your PDF Form: Launch WPS Office and open your interactive PDF form document.
- 3. Fill and Manage Data: Use the 'Form' and 'Edit' tabs to interact with form fields, insert text, apply signatures, and save your completed document.

Frequently Asked Questions
Why does my calculation script return an error or NaN?
This usually happens if the script references a field name that does not exist in the form, or if a field contains text instead of a number. Ensure all referenced fields are named correctly and use the 'Number()' function with an 'isNaN' check to default empty or invalid fields to zero.
Can I change the passing percentage threshold?
Yes. In the script, locate the threshold condition (e.g., result < 0.7). Change '0.7' to your desired decimal value. For example, for an 80% passing grade, change it to '0.8'.
Do custom JavaScript calculations work on mobile PDF viewers?
Most mobile PDF readers and web browsers have limited or no support for custom JavaScript in PDF forms. For the calculations to execute reliably, users generally need to open the form in a desktop PDF application that fully supports JavaScript.




