Using Check boxes in Forms
Check boxes allow your user to make single or multiple selections from a list.
Attributes
name
Usually refers to the name of the variable where the value entered on the form is to be stored.
value
Refers to the information or data entered or selected on the form.
checked
Displays a check mark in the desired input box. (See Code Example)
The HTML code:
Label <input type="checkbox" name="" value=""> or <input type="checkbox" name="" value=""> Label
Example:
Red <input type="checkbox" name="color" value="red">
Green <input type="checkbox" name="color" value="green">
Blue <input type="checkbox" name="color" value="blue" checked>
When using check boxes the name attribute must be the same for each check box.
In the example above, multiple check boxes would each share the name color.
In the example above multiple check boxes would include a different color in each value attribute.
The Label preceding or following the check box would match the value.
Now let's build a simple form: