How to Create Dependent Sub-Radio Buttons in Acrobat PDF Forms
Question details
The user wants to set up sub-radio buttons in a PDF form that only become active when a specific main radio button is selected.

- Product
- Adobe Acrobat PDF
- Device & OS
- not provided
- Scenario
- Designing an interactive PDF form with conditional logic for radio buttons.
- Observed behavior
- The user needs to configure a subgroup of radio buttons to dynamically switch between an enabled state and a disabled (grayed out) state based on the main group's selection.
Ensure you have access to form editing tools in your PDF editor and a basic understanding of adding JavaScript code to form fields.
Use a Custom Calculation Script in a Hidden Text Field
This method relies on creating a hidden text field to run a background calculation script that continuously evaluates the main radio button's value, enabling or disabling the subgroup accordingly.
By utilizing the calculation event of a hidden text field, the script triggers automatically whenever the user interacts with any field in the form. This is highly reliable for managing complex conditional formatting in interactive PDF forms.
Add your primary radio button group and name it "MainGroup". Assign export values to its options, such as "A", "B", and "C". Then, create your dependent radio button group and name it "SubGroup".
Insert a standard text field anywhere onto your PDF form. Right-click the field and open its Properties. Navigate to the General tab, and under Form Field properties, set it to 'Hidden'.
In the hidden text field's properties window, navigate to the Calculate tab. Select the 'Custom calculation script' radio button and click the Edit button.
Paste the following script into the editor: `if (this.getField("MainGroup").valueAsString == "B") { this.getField("SubGroup").readonly = false; } else { this.getField("SubGroup").readonly = true; this.getField("SubGroup").value = "Off"; }`. Click OK to save.
Exit the form editing mode. Click on option 'B' in the main radio button group. The sub-radio buttons will become interactive. Clicking 'A' or 'C' will disable the sub-group and clear any existing selections.

Create and Manage Documents Seamlessly with WPS Office
While advanced JavaScript calculations for dynamic fields are specific to Adobe Acrobat, WPS Office offers a highly capable, free alternative to create, edit, and fill standard PDF forms, alongside powerful Word, Excel, and PowerPoint tools.

Frequently Asked Questions
Why aren't my sub-radio buttons graying out as expected?
This usually occurs due to a typo in the JavaScript code. Verify that the hidden text field contains the exact names of your radio button groups. Because JavaScript is case-sensitive, referencing "maingroup" will fail if the actual field is named "MainGroup".
Can I apply this same script to checkboxes instead of radio buttons?
Yes. You can adapt the JavaScript to check the export value of a specific checkbox instead of a radio group. Simply change the target field name and expected value in the script, and set the readonly property of the dependent fields accordingly.
Do I have to use a hidden text field for this calculation?
While it is possible to place scripts in other triggers, like the 'Mouse Up' action on the main radio button itself, using a hidden text field's calculation event ensures the dependent fields' state updates dynamically and consistently whenever any related form value changes.
What is the purpose of the 'value = "Off"' line in the script?
The `value = "Off"` command ensures that the sub-radio buttons are unchecked when the main condition is no longer met. This prevents contradictory or invalid data from being submitted if the user changes their primary selection later.




