Sum PDF Form Values of 3 or More with Acrobat JavaScript
Question details
Calculate a total from Likert-scale form fields, including only values greater than or equal to 3.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form has fields named Question1 through Question75 and a separate field for the total.
- Observed behavior
- The total should add values of 3 or more and exclude lower or blank values.
Confirm that the question fields use numeric values and check their names in Acrobat's Prepare a form tool. Create a separate text field for the total if the form does not already have one.
Add a custom calculation script to the total field in Acrobat
Use this script to total values of 3 or more across Question1 through Question75.
Open the PDF in Adobe Acrobat, then select All tools > Prepare a form.
Right-click the total text field, select Properties, and open the Calculate tab.
Select Custom calculation script, click Edit, and enter: var total = 0; for (var i = 1; i <= 75; i++) { var f = this.getField("Question" + i); if (f && f.valueAsString !== "" && Number(f.value) >= 3) total += Number(f.value); } event.value = total;
Close the script editor and field properties, save the PDF, and enter sample answers in the question fields. Confirm that the total includes values of 3 or more but excludes lower and blank values.

Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDF and Office files. It does not replace Acrobat's custom form calculation setup or guarantee execution of Acrobat JavaScript, but it can help you work with documents alongside your PDF forms.

Frequently Asked Questions
How do I change the script for only 10 questions?
In the total field's custom calculation script, change the loop condition from i <= 75 to i <= 10. Make sure the fields are named Question1 through Question10.
What happens if a question field is blank or missing?
The script checks that each field exists and is not blank before adding its value, so blank or missing fields contribute nothing to the total.
Why is a selected radio button not included in the total?
In Prepare a form, open the radio button's Properties and check its export value. The script converts field values to numbers, so the export value must be numeric and at least 3 to be included.
Where can I check whether Acrobat JavaScript is enabled?
Open Acrobat Preferences, select JavaScript, and check Enable Acrobat JavaScript. The custom calculation needs JavaScript enabled to run.




