Thursday, July 10, 2008

Forms - Checkboxes

<input type="checkbox" name="spice" etc.

This creates a checkbox. The value attribute specifies the data that is sent to the server application when the checkbox is selected.

<input type="checkbox" name="spice" value="salt" />

You can have a set of checkboxes all with the same name. When these are submitted using get, the URL looks something like this:
http://www.somesite.com/form.html?chars&picture=&spice=salt&spice=chilly&spice=pepper

and the checkboxes will look like this:
<input name="spice" value="salt" type="checkbox">Salt

<input name="spice" value="pepper" type="checkbox">Pepper

<input name="spice" value="chilly" type="checkbox">Chilly


The checked="checked" attribute selects the items that are checked automatically when the web page is loaded.

No comments: