Calculate Total Points per Player in an Adobe Acrobat PDF Form
Question details
Calculate each player's total points by matching their name to corresponding score fields in a PDF form.

- Product
- Adobe Acrobat PDF forms
- Device & OS
- not provided
- Scenario
- A single-elimination scoresheet contains player names and point fields for multiple games.
- Observed behavior
- The total field should add the scores associated with every occurrence of the selected player's name.
Open the form in Acrobat's Prepare a Form tool and check the exact names of the player, score, and total fields. The example below assumes player fields p1 through p16 and corresponding score fields p1s through p16s.
Add a custom calculation script to the total field in Acrobat
Use this method when player and score fields follow a consistent naming pattern.
Open the PDF in Adobe Acrobat and select Prepare a Form from the tools. Identify or create the text field that will display the player's total.
Double-click the total field, open the Calculate tab, and select Custom calculation script. Click Edit to open the script editor.
Paste this script, replacing Bob with the exact player name and adjusting the field names and loop range to match your form: var playerName = "Bob"; var total = 0; for (var i = 1; i <= 16; i++) { if (this.getField("p" + i).valueAsString == playerName) { total += Number(this.getField("p" + i + "s").valueAsString); } } event.value = total;
Close the script editor, save the PDF, and enter matching player names and numeric scores in several rows. Check that the total field updates to their sum.

Work with scoresheets and documents in WPS Office
WPS Office is a free, lightweight alternative with familiar editing tools and support for common Office formats, making it easy to move existing files into your workflow. It does not replace Acrobat's custom PDF form JavaScript editor.

Frequently Asked Questions
Can the script use a name entered in another form field?
Yes. Replace the first line with a field reference such as var playerName = this.getField("targetPlayer").valueAsString; and change targetPlayer to the actual field name.
Why is the total not updating?
In Acrobat, check the total field's Calculate tab and confirm that the script references existing fields with the correct names. Also check that form calculations and JavaScript are enabled in the PDF viewer.
What if my scoresheet has more than 16 player fields?
Change the loop limit in the script from i <= 16 to the last numbered player field. Ensure each player field has a corresponding score field using the naming pattern in the script.
Does the player name have to match exactly?
Yes. The example compares the entered name with Bob exactly, including capitalization and spaces. Enter names consistently or modify the comparison to normalize them.




