Radio Button in HTML form
Radio buttons are mainly used when the user has to select only one among a group of options. Radio button has two states and can toggle between them.
Note: Several radio buttons can be grouped together so that only one radio button can be selected at any given time. We can group radio buttons by giving same name to all the radiobuttons.
A single radio button can be created as :
<input type="radio" name="radiogroupname" value="value of the object" checked>
Attributes of Radio Button Field:
Name: Specifies the group name of the object.
Value:Specifies the value of the radio button.
Checked: If given, the radiobutton will be selected else, it will not be selected.
Align: Specifies the alignment of the radio buttons.
Example of Radio button:
Gender: <input type="radio" name="grpGender" value="Male" Checked>Male
<input type="radio" name="grpGender" value="Female">Female
The above code places two radio buttons with a group name of "grpgender", one with a value "Male" and other one with value "Female". As the checked property is given for the first radio button it will be selected by default. This will give the output like :
Gender:
|