Calculate PDF Form Totals from Radio Button Selections in Adobe Acrobat
Question details
Calculate separate PDF form totals based on Choice 1 and Choice 2 selections across 15 radio button questions.

- Product
- Adobe Acrobat PDF forms
- Device & OS
- not provided
- Scenario
- A form contains 15 radio button groups and needs a separate calculated total for each choice.
- Observed behavior
- The desired result is for each total field to update according to the selected radio button values.
In Acrobat's Prepare a form tool, check the names of the 15 radio button groups and the export values assigned to each option. The example below assumes group names Q1 through Q15 and export values Choice1 and Choice2.
Count each radio button choice with Acrobat JavaScript
Use a custom calculation script in each total field to count the selections for its corresponding choice.
The script reads each radio button group's export value, not necessarily the visible label. Unselected groups are ignored.
The example calculates counts. If each selection has a monetary value, multiply the count by that value; if values vary by question, use a per-question amount instead.
Open the PDF in Adobe Acrobat and select All tools > Prepare a form. Confirm that the radio button groups are named Q1 through Q15 and that their option export values are Choice1 and Choice2.
Open the Properties of the Choice 1 total text field. On the Calculate tab, select Custom calculation script, click Edit, and enter: var count = 0; for (var i = 1; i <= 15; i++) { var field = this.getField("Q" + i); if (field && field.valueAsString === "Choice1") count++; } event.value = count;
Open the Choice 2 total field's Properties > Calculate > Custom calculation script > Edit. Use the same script, but replace "Choice1" with "Choice2", then save the script.
Close the form editor or select Preview, then select different options in the radio button groups. Check that each total matches its selection count and save the PDF.

Use WPS Office for everyday PDF and document work
WPS Office is a free, lightweight Office alternative with a familiar interface and Microsoft Office format compatibility for easier migration. Use its PDF tools for everyday document work; the Acrobat JavaScript calculation above should be created and tested in a compatible Acrobat viewer.

Frequently Asked Questions
Why does the script use Choice1 instead of the visible radio button label?
Acrobat JavaScript reads the radio button's export value. In Prepare a form, open the radio button's Properties and check its Options tab; change the script to match the actual export value.
How do I calculate an amount instead of a count?
In the total field's custom calculation script, replace event.value = count with event.value = count * 10, using the amount assigned to each selection. For different amounts per question, add the appropriate amount inside the loop instead of incrementing count.
What if my radio button groups have different names?
The example looks for Q1 through Q15 using this.getField("Q" + i). Rename the groups in Prepare a form or revise the script to reference your existing field names.
Why do the totals not update in my PDF viewer?
Some PDF viewers do not support Acrobat JavaScript. Test the form in Acrobat or Acrobat Reader, and check Preferences for JavaScript and automatic form calculation settings.




