Roots
Back

Radio Buttons

What to use radio buttons for

Radio buttons provide the user with the option to select one choice from many. For example they could be either male or female, but not both.

How to create radio buttons

<input type="radio" name="name" value="this-value">

name - This name identifies a group of radio buttons, of which one may be selected.
this-value - This is the value to be submitted if that particular radio button is selected.

For example;

<form action="form-process.php" method="get">
<input type="radio" name="gender" value="male"> I am a man<br>
<input type="radio" name="gender" value="female"> I am a woman<br>
<input type="submit" value="Submit">
</form>

I am a man
I am a woman
Note that the name is the same for both radio buttons, and it is the information in value which is sent by the form, not the text after the radio button.