Selection Controls: Radio Buttons
|
A radio button is a small round and white circle that allows the user to
select an item from a group. This is because a radio button is generally
accompanied by others. From a group of items, represented each by a
circle, when the user clicks one of them, none of the others is
selected. To change the selection, the user must click another choice in
the group.
|
Creating Radio Buttons
|
To create a radio button, use the <input> tag and specify the
type
attribute as radio. Here is an example:
To make your radio buttons effective, you should
always provide at least two radio buttons in a group.
|
Radio Button Properties
|
One of the most important attributes to set on the radio button is the
name. This attribute should be used even if you don't plane to use the
radio button in a script, since many radio buttons can use the same name,
this name will be helpful in determining what particular control has been
selected. Therefore, the same value (string) for the Name attribute
can be assigned to each radio button of the same group.
The checked attribute, as applied to the check
box, can be used in two circumstances, if you want one of the buttons in
the group to be selected by default, assign a true value to its checked
attribute. Here is an example:
You can also use the checked attribute in your script
to find out what radio button was clicked at one time.
|
Radio Button Events
|
Because it is first of all a button, the most fundamental event that a radio button can send to the browser is called OnClick. This event fires when the user clicks or select a particular radio button. You can therefore use it to take action as a response. |
Selection Controls: Combo Boxes
|
Like a group of radio buttons, a combo box allows the user to select an item from a group, namely a list. A combo box has the shape as a text box, except that it is equipped with an arrow on the right side of the control. This arrow control allows the user to display a list of items that are hidden by the text side of the combo box. When the list displays, the user select one item from the list. Once the item has been selected, the list retracts back to its original text-like size. |
Creating a Combo Box
|
To create a combo box, use a tag called select. This tag has to be closed. After typing the <select> tag, create each item that is part of the control using the <option> tag. Each item uses its own <option> tag. After listing the items, make sure you close the select tag as </select>.
Here is an example:
|
Combo Box properties
|
To select a default item from the combo box, use the selected attribute of the <options> tag. Here is an example:
|
Selection Controls: List Boxes
|
Like radio buttons or a combo box, a list box displays a list of items that the user can select from. Unlike a combo box, a list box displays a taller list and can even display all of its items all the time. |
Creating a List Box
|
Like a combo box, a list box is created using the <select> tag. Like the combo box, each item of a list box is created using the <option> tag. To make the control a list box, the <select> tag is equipped with an attribute called size. This attribute accomplishes two purposes: it makes the control become a list box and it sets the vertical size of the list box. In other words, it decides on the number of items the list box can display at a time.
Here is an example:
|
List Box properties
|
A list box can be configured to allow the user to select one item. To select an item from the list, set the selected attribute of its <option> tag to true.
Here is an example:
Unlike a combo box, a list box can be configured to allow
the user to select more than one item from the list. To allow this,
include the multiple attribute in the <select> tag. Here is an example:
|
List Box Events
|
The most commonly used and the most important event of a list is called OnChange. This event fires whenever the user makes a selection in the list box. This allows you to take appropriate actions.
No comments:
Post a Comment