How to Initialize Mutually Exclusive Radio Buttons in PDF JavaScript
Question details
The user wants to know how to properly set the initial state of mutually exclusive radio buttons in an Acrobat JavaScript dialog based on the value of another PDF form field.

- Product
- Adobe Acrobat PDF Form
- Device & OS
- not provided
- Scenario
- Writing an Acrobat JavaScript script to dynamically initialize the default selected state of a radio button group.
- Observed behavior
- The user is seeking the correct scripting logic, as attempting to initialize both true and false values independently for radio buttons in the same group may cause conflicts.
Ensure you have access to the PDF's JavaScript editor and verify that your radio buttons share the exact same group name in their properties so they function as mutually exclusive options.
Set Only the Target Radio Button to True
Because radio buttons in the same group are inherently mutually exclusive, you only need to assign the 'true' value to the one you want selected.
In Acrobat JavaScript, when radio buttons share the same field name but have different export values, they automatically become part of a mutually exclusive group. This means that setting one button in the group to true will automatically clear all other buttons in that group.
You do not need to explicitly set the unselected buttons to false. Trying to initialize both values independently is unnecessary and can cause logical conflicts in your form script.
Open your PDF form properties and ensure all related radio buttons have the exact same 'Name' field but unique 'Radio Button Choice' (export) values.
Navigate to the interactive dialog initialization script or the specific form field calculation script where you want to set the default state.
Write your JavaScript condition to evaluate the target PDF form field. Set only the specific radio button choice you want selected to true. For example: assign the condition directly to Rad0 or Rad1.

Handle Interactive PDF Forms with WPS PDF
WPS PDF offers robust tools for creating, editing, and filling interactive PDF forms. You can easily manage form fields, including checkboxes and mutually exclusive radio buttons, through an intuitive graphical interface without writing complex JavaScript.
- 1. Open WPS PDF: Launch WPS Office and open your PDF document using the WPS PDF tool.
- 2. Access the Form tab: Click on the 'Form' tab in the top navigation ribbon to reveal all interactive form editing tools.
- 3. Add or Edit Radio Buttons: Select the 'Radio Button' tool to add new mutually exclusive options, or double-click an existing radio button to easily modify its group name and default selection state.
- 4. Save the Form: Once configured, click 'Save' or press 'Ctrl + S' to preserve your interactive PDF form.

Frequently Asked Questions
Why are multiple radio buttons getting selected at the same time in my PDF?
If multiple radio buttons can be selected simultaneously, they do not belong to the same group. Ensure all radio buttons that should be mutually exclusive share the exact same 'Name' in their form field properties.
Do I need to write JavaScript to make PDF radio buttons mutually exclusive?
No, you do not need JavaScript for basic mutual exclusivity. Simply assigning the same field name to multiple radio buttons in any standard PDF editor makes them mutually exclusive automatically.
How do I read the selected value of a radio button group via Acrobat JavaScript?
You can retrieve the selected value using `this.getField("YourRadioButtonGroupName").value`. It will return the specific export value of whichever radio button is currently selected.
What happens if I set two radio buttons in the same group to true in my script?
Because the group is mutually exclusive, the system processes commands sequentially. Setting multiple radio buttons in the same group to true will result in only the last executed assignment remaining selected.




