PDF Editing Issues

How to Ignore the Off Value When Calculating PDF Radio Buttons

Nimra MalikNimra Malik Nov 3, 2026 868 views

Question details

The user needs to calculate values from PDF form radio buttons while explicitly excluding the unchecked 'Off' state to prevent calculation errors.

How to Ignore the Off Value When Calculating PDF Radio Buttons
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.
Before you start

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.

Solution 1Recommended

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'.

1
Open target field properties

Open your PDF form in editing mode. Right-click the destination text field where you want the calculated total to appear and select 'Properties'.

2
Navigate to calculation settings

Click on the 'Calculate' tab inside the Properties dialog box.

3
Insert custom calculation script

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;

4
Save and test

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 Custom JavaScript to Exclude the 'Off' Value
Field Naming Convention: This script assumes your radio buttons use a sequential naming convention (e.g., A1PA1, A1PA2, A1PA3). Make sure to update the string 'A1PA' and the loop limit in the script to match your actual form fields.
Edit Interactive PDF Forms Easily

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. 1. Open PDF in WPS Office: Launch WPS Office, open your PDF document, and navigate to the 'Form' tab on the top ribbon.
  2. 2. Configure form fields: Insert your radio buttons and double-click them to set their specific export values in the 'Options' tab.
  3. 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.
Intuitive interface for inserting and configuring interactive radio buttons.Supports advanced JavaScript logic for complex form calculations.Highly compatible with standard Adobe Acrobat PDF form formats and logic.Lightweight, fast, and free to download for everyday PDF tasks.
microsoft office alternative - wps office

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.