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.
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.
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 :
Radio button or Checkbox
In a web form if we can select one of the several options then we will go for Radio buttons.
If the user can select more than one options then we will go for checkbox.
How many languages you know ? ( Use checkbox here )
Your gender ( Use radio button here )