Understanding Radio Buttons

Radio buttons are buttons which provide a group of options which are mutually exclusive so selecting one radio button automatically deselects the rest of the buttons in that group. This is often used in quizzes, tests and surveys to provide multiple-choice questions which allow only one of the answers to be chosen.

 

image\ebx_-1831385688.jpg

 

As is clear from the example above radio buttons have to be part of a particular set and each set must be distinct from the other. If this was not the case a button on the second question could deselect an option on the first question or vice versa.

You can tell Opus which group a radio button belongs to using the Group Index which is on the Button tab of the Properties dialog for each button. In the example above we need two groups.

 

image\ebx_15926254.jpg

 

All the buttons for the first question – Good, Indifferent and Bad – are set to Group 1.

All the buttons for the second question – Yes, Perhaps, No – set to Group 2.

To allow you to use radio buttons on master pages and to save the settings between pages it is also necessary to separate radio button groups like this even when they are on different pages.

Stored Settings

Opus automatically stores the settings for any group of radio buttons. This is very useful if you want to allow your user to return to an option and change their mind. For example, if you have a series of questions on different pages you may wish to allow your user to select and answer and then return to check and amend those answers at any point.

Opus stores the button currently chosen in a variable. The ID of the button is stored in a variable called RADIO_GROUP_nn_ID (where nn is the group number).

image\ebx_197904247.jpg

The ID is a number representing where the button is listed in the Opus Organiser in relation to the other buttons and just to be confusing the index starts at 0. So the first button in a group has an ID of 0, the second is 1 and third is 2 and so on. By default the ID of the group is set to –1 which means no button has been selected.

In the example above <RADIO_GROUP_1_ID would be 0 (for the first button and RADIO_GROUP_2_ID would be 1 for the second button.

Note:
Be careful that the order of the buttons in the organiser, reading from the bottom up, is the order you require – it can be easy to give a button your second answer when it is actually the third button you created and this can get confusing.

If you need to use more radio buttons groups than we have provided variables for then you can simply add your own as you would any other variable – just remember to keep the same naming style and set the initial value to –1 unless you want a particular button to be initially down.

Reset Variables

If you want to clear the previous answers given (perhaps to allow the user to have another go at a test then you can use the Reset All Variables action from the Programming tab. Alternatively you can reset individual groups of buttons by using the Set Variable action to set the RADIO_GROUP_nn_ID back to –1.

 

Related Topics:

Adding a Button

Button Properties