Radio Buttons

Radio buttons are the selfish cousins to check boxes. If you
have a selection of answers or options but only one of the options can be
selected at a time, then you should use radio buttons. Once again, radio buttons
are created using the <input> element setting the
type attribute to Radio.

<input name="Question1" type="radio" value="Porto">

Radio buttons, like check boxes, have a checked attribute in HTML, which again takes no value. If you
supply this attribute in the control, the check box is checked by default:

<input name="Question1" type="radio" checked>

If you supply no value for the value
attribute, it is set to "on" by default.

Contrary to check boxes, to connect a set of radio buttons, you
must supply each radio button in your group with the same name. For example:

How it Works

The method of transmission is changed to GET, so the query string is visible once more. A
questionnaire is actually the one time when this might be useful. It confirms
the answer that's selected, which would admittedly be more
useful if the answer wasn't already displayed in the body of the page. That
aside, take a quick look at the programs. The first program, radio.html, sets three radio button controls. They all have
the same name, Question1, but with three different values to reflect the
different answers: