Calculate PDF Form Totals with Radio Buttons in Adobe Acrobat
Question details
Calculate a PDF form total by adding or subtracting amount fields according to the selected radio button.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form contains multiple amount fields and a radio button group that selects the calculation to apply.
- Observed behavior
- The Total field should show the sum or the subtraction result based on the selected radio button.
Open the PDF in Adobe Acrobat and enter Prepare a form. Check the exact names of the amount fields and radio button group, as well as the export value assigned to each radio button.
Add a custom calculation script to the Total field
Use this method when a radio button selection determines whether the form adds or subtracts its amount fields.
The example assumes three numeric fields named Amount.0, Amount.1, and Amount.2, plus a radio button group named Group1 with export values sum and subtract. Subtraction is performed in field order: Amount.0 minus Amount.1 minus Amount.2.
In Adobe Acrobat, open the PDF and select All tools > Prepare a form. Create a text field for the total if the form does not already have one.
In Prepare a form, open each radio button's Properties and check its group name and Options export value. This example uses the group name Group1 and export values sum and subtract.
Open the Total text field's Properties, select the Calculate tab, choose Custom calculation script, and click Edit.
In the JavaScript editor, enter: var a = Number(this.getField("Amount.0").value); var b = Number(this.getField("Amount.1").value); var c = Number(this.getField("Amount.2").value); var choice = this.getField("Group1").valueAsString; if (choice == "sum") event.value = a + b + c; else if (choice == "subtract") event.value = a - b - c; else event.value = ""; Replace the field names and export values with those in your form, then click OK and close Properties.
Use Preview in Prepare a form, enter numeric amounts, and select each radio button. Confirm that Total shows the expected result, then save the PDF.

Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. Its format compatibility helps you move existing files into your workflow; use Adobe Acrobat to author the custom calculation script described above.

Frequently Asked Questions
Where do I find the radio button export values?
In Acrobat's Prepare a form tool, open each radio button's Properties and check the export value on the Options tab. Use those exact values in the script's comparisons.
Why is the Total field blank?
The example leaves Total blank when the selected value is neither sum nor subtract. Check the group name and export values in the radio buttons' Properties, then verify the names used in the Total field's Calculate script.
Can I change the subtraction order?
Yes. In the Total field's custom calculation script, change the expression after event.value. For example, b - a - c subtracts Amount.0 and Amount.2 from Amount.1.
Will the calculation work in every PDF viewer?
Not necessarily. The calculation uses Acrobat JavaScript, which some PDF viewers do not support. Save the form and test it in the viewer intended for recipients.




