PDF Editing Issues

How to Loop Through Radio Button Widgets in Acrobat JavaScript

Adam DavisAdam Davis Nov 5, 2026 869 views

Question details

The user wants to inspect each widget in an Adobe Acrobat radio-button group using JavaScript to find which specific option is selected.

How to Loop Through Radio Button Widgets in Acrobat JavaScript
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Developing or modifying an interactive PDF form with Acrobat JavaScript and needing to verify the status of individual radio buttons.
Observed behavior
The user needs a script to iterate over radio button widgets, or a more efficient method to extract the selected value from a radio group.
Before you start

Before writing your JavaScript code, ensure that all radio buttons in your group share the exact same field name but have distinct export values configured in their properties.

Solution 1Recommended

Loop Through Widgets Using Acrobat JavaScript

Use a `for` loop to inspect each individual widget in the radio-button group by its index.

In Acrobat, multiple radio buttons that share a name are treated as a single field with multiple widget representations. You can determine the number of widgets by checking the length of the exportValues array and then loop through them.

1
Access the JavaScript Console

Open your PDF form in Adobe Acrobat, enter Prepare Form mode, and open the JavaScript Console (Ctrl+J) or the calculation script window for your target field.

2
Define the Field Variable

Get the radio-button group by defining a variable: `var f = this.getField("Group1");`

3
Determine Widget Count

Count the number of available options in the group by checking the export values: `var n = f.exportValues.length;`

4
Execute the Loop

Write a `for` loop to iterate through each widget and check if it is selected using the `isBoxChecked()` method: `for (var i = 0; i < n; i++) { console.println(this.getField("Group1." + i).isBoxChecked()); }`

Loop Through Widgets Using Acrobat JavaScript
Edit PDF Forms Effortlessly

Create and Manage Interactive PDF Forms with WPS Office

WPS Office provides a comprehensive PDF editor that allows you to easily design interactive forms, manage radio buttons, and fill out documents without relying on complex scripting.

  1. 1. Open your PDF Document: Launch WPS Office and open the PDF file you wish to make interactive.
  2. 2. Access the Form Tools: Navigate to the 'Form' tab located in the top ribbon menu.
  3. 3. Insert Form Fields: Select 'Radio Button' or other interactive fields to place them directly onto the document.
  4. 4. Save the Interactive Form: Configure your field properties and save the document. Your forms are fully compatible with other major PDF viewers.
Seamless compatibility with standard PDF form fieldsEasily insert and manage radio buttons, text fields, and checkboxes visuallyCross-platform support for Windows, Mac, and mobile devicesFree and lightweight alternative to heavy PDF editors
microsoft office alternative - wps office

Frequently Asked Questions

Why do my PDF radio buttons all get selected at once?

This happens if your radio buttons do not share the exact same 'Field Name' or if they have identical 'Export Values'. To behave as a mutually exclusive group, they must share a common name but feature distinct export values.

Can I use standard JavaScript arrays in Acrobat?

Yes, Acrobat JavaScript is based on Core JavaScript, so standard array methods work. However, Acrobat's DOM objects like `getField` return specific Field objects, requiring you to access properties like `exportValues.length` to iterate properly.

How do I clear the selection of a radio button group using JavaScript?

You can clear a radio button group by setting its value to 'Off' (with a capital O). For example: `this.getField("Group1").value = "Off";`

Is Acrobat JavaScript supported in all PDF viewers?

No, Acrobat JavaScript is fully supported in Adobe Acrobat, Adobe Reader, and robust editors like WPS PDF. Basic viewers, such as native browser PDF viewers, often cannot execute advanced JavaScript calculations or loops correctly.