|
Most of the controls (which excluded just a few of
them) are created using a special tag called input. To use the
<input> tag, you must let the browser know what type of input
control or object you want to create. The <input> tag uses an
attribute called Type that allows you to specify the kind of
control you want. This is done by assigning the name of the control
to the Type attribute. Some browsers, including Internet Explorer, can
recognize all of the HTML GUI controls that we will be using here.
Therefore, you can just assign the name of the control to the Type
attribute. In some circumstances, and based on HTML standards, you should
assign the control type as a string.
Like the <br>, some <p>, and some
<li>
tags, the <input> tag doesn’t need to be closed.
|
|
Selection Controls: Check Boxes |
|
|
A check box is a small square box that allows the user to select an item
or to deselect it. The user makes this decision by clicking in the small
square box. By default, or depending on how the control is configured, the
square box is white and empty. This indicates that it is false or off.
When the user clicks it, a small check mark appears in the square box,
indicating that it is true or on.
|
|
To create a check box, use the <input> tag and specify the
control type as checkbox, CheckBox, or CHECKBOX. Here is an example:
|
|
A check box doesn't display what it is used for. Therefore, you should (always) add a label close to it to help the user
know the role of this control.
If using many check boxes in a group, the user is able
to click or select as many different check boxes that the application
designer allowed.
|
|
As described already, when the user clicks the check box, its value becomes
on or true. You can programmatically set this state by using the checked
attribute of this tag. If you assign it a true value, the check box
becomes checked. Otherwise, it would be unchecked. Here is an example of
using the tag:
<input type="checkbox" checked="true">
If you plan to use a check box in a script, you should
give it a name. This is done by assigning a string to the Name
attribute. |
|
The most popular and probably the most important event of a check box
fires when the user clicks the check box, selecting or deselecting it.
Therefore, you can use the OnClick event of the check box to find out
whether the control has been selected or not; if so, you can decide what
to do in response. |
|
|