Switches (radiobutton)

Switches are used when it is necessary to select one single option from the proposed ones. If you want to select several options, you should prefer the checkboxes.

Switches are created as follows.

<Input type = "radio" parameters>

Field parameters are listed in the table.

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.
Checked Sets the default item.

The name of the field (parameter name ) for all elements of the group must be the same. It is in this case that the browser correctly marks the selected items (example 1).

Example 1. Using switches

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> Switches </ title>
</ Head>
<Body>

<Form action = "/ cgi-bin / handler.cgi">
<P> <b> How do you think the abbreviation "OS" stands? </ B> </ p>
<P> <input type = "radio" name = "answer" value = "a1"> Officer composition </ p>
<P> <input type = "radio" name = "answer" value = "a2"> Operating System </ p>
<P> <input type = "radio" name = "answer" value = "a3"> Large striped flies </ p>
</ Form>

</ Body>
</ Html>

As a result, we get the following (Fig. 1).

Fig. 1

Fig. 1. Kind of switches

Copyright © www.htmlbook.ru