Checkbox

Flags are used when it is necessary to choose two or more variants from the offered ones. If you want to select only one option, then you should prefer the switches (radiobutton).

The check box is created as follows.

<Input type = "checkbox" options>

Field parameters are listed in Table. 1.

Table. 1. Flag options
Parameter Description
Name The name of the field. It is intended for the form handler to be able to identify this field.
Value The value of the field determines what will be sent to the server when the checkmark is ticked.
Checked If this parameter is checked, a check mark in the field will be added automatically.

The creation and use of the checkboxes is shown in Example 1. Note that the value of each flag in the group is different. So the server program can determine which item was flagged.

Example 1. Using the checkboxes

Valid HTML
<! DOCTYPE HTML PUBLIC "- // W3C // DTD HTML 4.01 // EN" "http://www.w3.org/TR/html4/strict.dtd">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text / html; charset = windows-1251">
<Title> Checkboxes </ title>
</ Head>
<Body>

<Form action = "/ cgi-bin / handler.cgi">
<P> <b> What operating systems are you familiar with? </ B> </ p>
<P> <input type = "checkbox" name = "option1" value = "a1" checked> Windows 95/98 </ p>
<P> <input type = "checkbox" name = "option2" value = "a2"> Windows 2000 </ p>
<P> <input type = "checkbox" name = "option3" value = "a3"> System X </ p>
<P> <input type = "checkbox" name = "option4" value = "a4"> Linux </ p>
<P> <input type = "checkbox" name = "option5" value = "a5"> X3-DOS </ p>
</ Form>

</ Body>
</ Html>

The result of this example is shown in Fig. 1.

Fig. 1. Kind of checkboxes in the Opera browser

Fig. 1. Kind of checkboxes in the Opera browser

Copyright © www.htmlbook.ru