How do you Group a Set of Radio Buttons in an HTML Form ?

In order to group a set of radio buttons, you should give all of them the same name.
For example, if you were to create a group of radio buttons for the top most popular video game consoles, then you would create it like so.
<form>
<!-- brand of video gameĀ  console-->
<input name ="video-game-console-brand" type="radio" value="wii"
    checked="checked"/>Nintendo Wii
<input name ="video-game-console-brand" type="radio" value="ps3"/>
    Sony Playstation 3
<input name ="video-game-console-brand" type="radio" value="ps3"/>
    Microsoft XBOX 360 Elite
</form>

Notice how all the 3 radio button declarations have the same name video-game-console-brand. This declaration will rendered the FORM as shown below, with the Nintendo Wii pre-selected.

Nintendo Wii

Sony Playstation 3

Microsoft XBOX 360 Elite

, , {0}

Leave a Reply