- Radio buttons allow choosing only one option from several available options.
- Names of all the radio buttons of same group must be same.
- They are also created using HTML tag but type attribute is set to radio.
Here is an example of radiobutton control which will show three radiobuttons with names undergraduate,graduate and post graduate respectively:
<input type= “radio” name= “qualification” value= “ugr” checked /> Undergraduate<br />
<input type= “radio” name= “qualification” value= “gr” /> Graduate<br />
<input type= “radio” name= “qualification” value= “pgr” /> Post Graduate
To see live output : Visit Try Yourself Editor
Here is the list of Attributes for creating radiobutton control:
|type||(Required) It defines which input field to create.for radiobutton input control it will be set to radio.|
|name||(Optional) It is important as the field will be identified in the other file or server by the value of this attribute.|
|value||(Optional) The value that will be used if the radiobox is selected.|
|disabled||(Optional) It specifies that the input field will be disabled. Generally, it is used alone without any value.|
|checked||(Optional) It will specify that these will be shown checked initially. Generally, it is used alone without any value.|