Custom radio buttons and selection groups

Hi all,

I am creating custom radio buttons and I would like to have them work in a Selection Group. Currently, I have my radio bullet - a dynamic panel with two states, selected or unselected - and a label for each option. They are grouped together.

OnClick on each of those option groups, I set the dynamic panel to its selected state and change the option group selection to true. If the option group is already selected, it changes the dynamic panel to unselected and the selection to false.

Now, I have four options in my widget, and I assigned them to a Selection Group. The objective is that when the user clicks on one option, the other is deselected. I assumed this should work on its own, but it is not working.

Any ideas?

You don’t have to use dynamic panels for this kind of two-state radio button interaction, and using the “Selection Groups” feature doesn’t work with dynamic panels anyway, as there is no OnSelected event or selected styling available for dynamic panels. You can select a dynamic panel and assign it to a selection group though, so I suppose it is reasonable to expect this to work …but alas, it doesn’t.

You can achieve this by using a basic widget, like an ellipse or an image for your radio buttons, which have built-in states for selected, unselected, disabled, etc. Just create a unique style for your button when it is selected, then for OnClick use “select This” and group selection will work properly.

See this demo of various radio button methods.
https://3t2zrz.axshare.com

Radios.rp (296.5 KB)

The Home page shows what happens when you try to use dynamic panels with selection groups, as I’m guessing you tried. When you say you have a label for each option, I didn’t know if the labels were different or just copies, so the example changes the labels when selected. There is a copy of these dp’s with a fix --setting all the dynamic panels to “unselected” state then setting “This” to selected. Brute force and crude, but it works. At least you can copy & paste the code from panel to panel. For longer lists of radio buttons, you could turn one of these dynamic panels into a repeater list and this approach still works.

Better Solution page shows a simpler way to handle styled radio buttons. Each item has only one radio ellipsis widget with two interaction sytles: default and selected. The selected style obeys the selection group so that only one in the group can be selected. The setup and code is just a lot simpler vs using dynamic panels.

Better Solution with groups builds on this approach by grouping the ellipsis and text and assigning the interaction code to the group. Simpler yet.

Example using images shows that you can use this same approach with images. Just set the selected style to load a different image. So, you can style your radios in Photoshop, Illustrator, etc., even use animated GIFs. Of course, you can use Axure’s built-in animation effects, too, as I did with the “primate list” goofiness.

2 Likes

I am sorry to say but those radio buttons do not have an initial state … so on page load no radio button is selected? Is there any way to fix that ? Regards

Yes, in the Properties panel there are checkboxes for the default states at page load. You can choose Selected or Disabled. You can also assign Selection Groups so that only one radio button is selectable within that group.

2 Likes

Thanks, at first nothing changed when i selected “the selected” state but now its working. Well thanks for your reply.