HTML Check box Form input type="checkbox"
Here you can see how check boxes are used to gather options from you web page visitors.
The Check box Form element is a usefull way of collecting one or multiple options from a selection of choices displayed on your web page form
Format the HTML check box using the attributes in the table below.
| Attribute | Description |
|---|---|
| name | Name of variable submitted with form |
| value | Text or value contained within variable |
| checked | This is set for the box to be checked by default |
HTML Check box Example with submit and reset button
|
<form action="checkBox.php" method="post"> <input type="checkbox" name="opta" value="Option A" checked="checked" /> Choose Option A <input type="checkbox" name="optb" value="Option B" /> Choose Option B <input type="checkbox" name="optc" value="Option C" /> Choose Option C <input type="submit" value="Submit" /> <input type="reset" /> </form> |
You may have noticed the first type also had the extra attribute checked ="checked" , this is shown in the example as the first box or Option A as checked. Its normally enough just to put the word checked but as these pages are XHTML compliant it needs to shown as above
If you want you users to be able to choose only one option from a list, then you need to look at HTML radio boxes