PDF Editing Issues

Sum PDF Form Values of 3 or More with Acrobat JavaScript

Muhammad TalhaMuhammad Talha Nov 19, 2026 868 views

Question details

Calculate a total from Likert-scale form fields, including only values greater than or equal to 3.

Sum PDF Form Values of 3 or More with Acrobat JavaScript
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the form editor

Open the PDF in Adobe Acrobat, then select All tools > Prepare a form.

2
Open the total field properties

Right-click the total text field, select Properties, and open the Calculate tab.

3
Enter the calculation script

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;

4
Save and test the form

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.

Add a custom calculation script to the total field in Acrobat
Match the script to your form: Change "Question" and the loop limit if your field names or number of questions differ. For radio buttons or other choice fields, ensure their exported values are numeric.
Free Microsoft Office alternative

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.

View PDF forms alongside your other documentsWork with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXUse a familiar interface for an easier move from Microsoft OfficeAccess a free, lightweight office suite
microsoft office alternative - wps office

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.