How to Get the Fill Color of a Selected Acrobat Radio Button
Question details
The user needs to retrieve the fill color of the currently selected radio button in a PDF form.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Using JavaScript to read appearance properties of form fields in a PDF document.
- Observed behavior
- Acrobat's fillColor property returns the color of the first option field in the group rather than the color of the currently selected radio button.
Ensure you have access to the PDF's JavaScript console or form field calculation scripts, as retrieving specific widget properties requires custom scripting.
Assign Color Based on the Selected Export Value
Since the fillColor property targets the first widget by default, use a script to check the event.target.value and manually assign or read the corresponding color.
In Adobe Acrobat, a radio button group shares a single field name but contains multiple widgets (the individual buttons). Calling getField("RadioGroup").fillColor typically returns the appearance property of the first widget in the group array, rather than the currently active one.
Use event.target.value or this.getField('YourRadioGroup').value in your script to determine which radio button option the user currently selected.
Create a JavaScript switch or if statement that maps each possible export value to its corresponding color array (e.g., color.red, color.blue, or ["RGB", 1, 0, 0]).
Return the mapped color variable to your target script instead of trying to read the widget's native fillColor property directly.

Edit PDF Forms Easily with WPS Office
Having trouble with complex form scripts in Adobe Acrobat? Try WPS Office. It provides a lightweight, free, and highly compatible suite for editing PDFs, Word, Excel, and PowerPoint files without the steep learning curve.

Frequently Asked Questions
Why does fillColor return the wrong color in a radio group?
A radio button group is treated as a single field with multiple widget children. The fillColor property reads from the root field or first child widget, disregarding the currently checked state of other widgets.
Can I use event.target.value to get the selected button's color directly?
No, event.target.value only returns the export value (typically a text string like 'Option1' or 'Yes') of the selected radio button, not its appearance properties.
How do I reference a specific radio button widget in Acrobat?
You can use the getWidget(index) method on the field object to reference a specific child widget by its index, allowing you to check its individual properties.




