Creating check boxes:
- A check box is either selected or not.
- Unlike radio buttons, check boxes can be deselected.
- A check box can be unselected if the user clicks inside the check box.
- On the other hand, a radio button cannot be deselected if you click on the radio button.
- A radio button can be deselected by clicking on some other radio button choice.
- To create a check box, use the <input> tag and set the type attribute to “checkbox” as:
<input type="checkbox">
Naming a check box: using ‘name’ attribute, we can value the checkbox to process in the form
<input type="checkbox" name="language"> HTML
Note: You can’t use a different name for every check box you specify in the list. Related choices represented with check boxes can be grouped with a same name.
Select languages known:
<input type="checkbox" name="language">.Net
<input type="checkbox" name=" language ">Java
<input type="checkbox" name=" language ">Python
Setting value: By default, when a check box is selected and that choice is submitted to the server, the value of the check box is “on.” You can, however, assign a different value to a check box, by using the value attribute.
Select languages known:
<input type="checkbox" name="language" value=”dotnet”>.Net
<input type="checkbox" name=" language" value = “java”>Java
<input type="checkbox" name=" language" value = “python”>Python
Default selection: We can check the option among specified when user have to select at least one among all.
Select languages known:
<input type="checkbox" name="language" value=”dotnet” checked>.Net
<input type="checkbox" name=" language" value = “java”>Java
<input type="checkbox" name=" language" value = “python”>Python