20.3. Checkboxes in XHTML MP

The following markup code creates a checkbox in XHTML MP:


<input type="checkbox" name="name_for_this_element"/>


Checkboxes of the same group should have the same name, like this:


<input type="checkbox" name="xhtml_mp_tutorial_chapter" value="1"/>
<input type="checkbox" name="xhtml_mp_tutorial_chapter" value="2"/>
<input type="checkbox" name="xhtml_mp_tutorial_chapter" value="3"/>


The value attribute defines the value to be sent to the server when the checkbox is checked. For example, if the first and second checkboxes in the above code are checked, the values "1" and "2" can be retrieved with the parameter name "xhtml_mp_tutorial_chapter" at the server-side.

Checkboxes are not checked by default. A checkbox will be checked initially if the checked attribute is specified, like this:


<input type="checkbox" name="xhtml_mp_tutorial_chapter" value="1" checked="checked"/>


The checked attribute only accepts "checked" as its value.


20.4. Radio Buttons in XHTML MP

The following markup code creates a radio button in XHTML MP:


<input type="radio" name="name_for_this_element"/>


Like checkboxes, radio buttons of the same group should have the same name. In a group of radio buttons, only one radio button can be in the checked state.


<input type="radio" name="xhtml_mp_tutorial_chapter" value="1"/>
<input type="radio" name="xhtml_mp_tutorial_chapter" value="2"/>
<input type="radio" name="xhtml_mp_tutorial_chapter" value="3"/>


The value attribute defines the value to be sent to the server. For example, if the second radio button in the above example is checked, the value "2" will be associated with the parameter name "xhtml_mp_tutorial_chapter". If the form is submitted, the name-value pair can be retrieved at the server.

Like checkboxes, radio buttons are not checked by default. A radio button will be checked initially if the checked attribute is specified, like this:


<input type="radio" name="xhtml_mp_tutorial_chapter" value="1" checked="checked"/>


The checked attribute only accepts "checked" as its value.


Previous Page Page 31 of 36 Next Page


Feedback Form (ExpandCollapse)

What do you think about this web page?






(Optional) Please provide us more details. For example, suppose you select option 2 above, can you tell us specifically what information is missing? You can also suggest anything that can help us improve this web page.

(Optional) Your name:

(Optional) Your email address:

Please enter again to confirm:

Due to the amount of messages we received, we may not be able to reply to all messages.

A button for going back to the top of this page