Working with Radio ButtonsRadio buttons are an either/or interface element that let the user pick one (and only one) choice within a group of options. Radio buttons should be used when one of those options is required. As shown in Figure 7.9, the form uses radio buttons to let the hypothetical car buyer choose between a two-door or four-door automobile. In this case, you can only pick one of these choices, and you must make a choice. Figure 7.9. Radio buttons are the best way to let the user pick only one choice from a group of options.
As seen in Script 7.12, it doesn't take much scripting to check that one button is selected. We use a technique where we loop through each button and check its status and then turn the radio buttons' label and buttons red and bold if no button is picked. Script 7.12. Only one radio button may be checked, and this JavaScript is there to enforce the interface law.
To make sure that the user picks a radio button:
|