Handle an Unselected Radio Button in an Acrobat Form Calculation
Question details
Set a PDF form calculation to display N/A or zero when no radio button is selected and use the selected value as the denominator otherwise.

- Product
- Adobe Acrobat PDF forms
- Device & OS
- not provided
- Scenario
- A calculated form field divides the value of TGI by the selected value of the MFI80 radio-button group.
- Observed behavior
- The calculation should show a fallback value when the radio-button group has no selection and calculate the quotient when a button is selected.
In Acrobat, open the PDF in Prepare a Form and check the exact field names for the numerator, radio-button group, and calculated result. Confirm that the radio buttons use numeric export values for the denominator.
Check the radio-button value in the Acrobat calculation script
Use a custom calculation script to display N/A when the group value is Off and divide by the selected value otherwise.
An unselected Acrobat radio-button group normally has the value "Off". Store the field value in a variable and test that variable rather than using the field name as an undefined JavaScript variable.
In Acrobat, open All tools > Prepare a form, then open Properties for the field that should display the calculation result.
On the Calculate tab, select Custom calculation script and click Edit. Enter: var calculatedPDiff = this.getField("MFI80").value; if (calculatedPDiff == "Off") { event.value = "N/A"; } else { event.value = this.getField("TGI").value / calculatedPDiff; }
In the script editor, replace MFI80 and TGI with your radio-button group and numerator field names if they differ, then save the script and close Properties.
Use Preview in Prepare a form to check the result with no radio button selected and with each button selected. Confirm that selected export values are nonzero numbers.
Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with documents, spreadsheets, presentations, and PDFs. Its Microsoft Office format compatibility makes it easy to move existing files. Use Acrobat to edit and test the Acrobat-specific calculation script.

Frequently Asked Questions
Why does the script check for "Off"?
An Acrobat radio-button group normally returns "Off" when no button is selected. The script checks that value before using the selection as a denominator.
Where do I add the calculation script in Acrobat?
Open All tools > Prepare a form, open Properties for the result field, and choose Calculate > Custom calculation script > Edit.
How can I display zero instead of N/A?
In the custom calculation script, change event.value = "N/A" to event.value = 0, then test the unselected state in Preview.
What if a selected radio button has a value of zero?
Division by zero will not produce a useful result. In Prepare a form, check the radio button's Properties and give it a nonzero numeric export value, or add a separate zero check to the script.




