Radio Button in HTML form

Gender: Male Female Others

HTML form radio buttons 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 for all the radiobuttons.

A single radio button can be created as :
<input type="radio" name="groupname" value="value1" checked>
HTML form radio buttons input types to collect user selected options with attributes

Attributes of Radio Button Field:

AttributeDescription
NameSpecifies the group name of the radio button. One group of radio button will have same name through which it can be referenced.
valueValue of the radio button. Each radio button will have different values in a group.
CheckedRadio button will be selected. In a group of buttons one can be selected.
AlignSpecifies 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: Male Female

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.

Example :

How many languages you know ? ( Use checkbox here as user can slect more than one choice )
Your gender ( Use radio button here as user can select one choice )

Checkbox in a form


HTML Form Drop down Listbox Checkbox in a form

Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com










    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer