How to Ignore the Off Value When Calculating PDF Radio Buttons
Question details
The user needs to calculate values from PDF form radio buttons while explicitly excluding the unchecked 'Off' state to prevent calculation errors.

- Product
- PDF Form Editor
- Device & OS
- not provided
- Scenario
- Creating or editing an interactive PDF form with radio buttons where the selected numerical values need to be summed into a total field.
- Observed behavior
- Unchecked radio buttons output a text value of 'Off', which interferes with mathematical sum calculations and causes errors in the total field.
Ensure you have access to a PDF editor that supports JavaScript form calculations, and identify the exact field names of the radio buttons you wish to sum.
Use Custom JavaScript to Exclude the 'Off' Value
Write a custom JavaScript calculation that iterates through the radio button fields, skips the text 'Off', and only adds valid numeric values.
By default, PDF viewers return the string 'Off' when a radio button is unchecked. By writing a short JavaScript loop, you can instruct the form to check each radio button's value and strictly add it to the total only if it is not 'Off'.
Open your PDF form in editing mode. Right-click the destination text field where you want the calculated total to appear and select 'Properties'.
Click on the 'Calculate' tab inside the Properties dialog box.
Select the 'Custom calculation script' option and click the 'Edit' button. Enter your JavaScript loop. For example: var total = 0; for (var i = 1; i <= 6; i++) { var value = this.getField('A1PA' + i).valueAsString; if (value != 'Off') total += Number(value); } event.value = total;
Click 'OK' to save the script, then close the Properties window. Toggle the radio buttons in your form to verify that the total updates correctly and ignores unselected fields.

Use the Built-In Sum Calculation
Utilize the default sum function in the PDF editor, which often automatically filters out non-numeric text like 'Off' without requiring custom code.
Create and Calculate PDF Forms Seamlessly with WPS Office
WPS Office offers a comprehensive PDF form editing environment. You can quickly add radio buttons, assign export values, and utilize built-in calculations or custom JavaScript without compatibility issues.
- 1. Open PDF in WPS Office: Launch WPS Office, open your PDF document, and navigate to the 'Form' tab on the top ribbon.
- 2. Configure form fields: Insert your radio buttons and double-click them to set their specific export values in the 'Options' tab.
- 3. Apply calculations: Add a text field for your total, double-click it to open Properties, go to the 'Calculate' tab, and apply your preferred sum method or JavaScript.

Frequently Asked Questions
Why do PDF radio buttons return an 'Off' value by default?
According to standard PDF specifications, when a radio button group is created, it assigns the specific export value of the selected button. However, if no button in that group is selected, the system defaults to returning the string value 'Off'.
Can I permanently change the default 'Off' value to a zero?
You cannot directly change the default unselected system state name from 'Off' to zero in the field properties. Instead, you must handle the conversion using custom JavaScript in your calculation fields to treat the 'Off' string as a numerical zero.
Does the built-in Sum calculation handle text values automatically?
Yes, in most advanced PDF editors, the built-in Sum calculation is programmed to ignore non-numeric strings (like 'Off') automatically. This provides an easy alternative to writing custom JavaScript when summing multiple fields.




