JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Drop-down Lists

You use drop-down lists to create a single-selection drop-down list control. (You can't select multiple items in this control because when you make a selection from the list, the list closes automatically.) You can see a drop-down list at work in Figure 17.4; this is the DropDownLists example on the CD-ROM—where I'm making a selection.

Click To expand
Figure 17.4: A drop-down list.

After you've selected an item in a drop-down list, you can use the control's SelectedItem and SelectedIndex properties to work with the selection. The DropDownLists example displays the selection you've made, as you see in Figure 17.5.

Click To expand
Figure 17.5: Making a selection in a drop-down list.

As with Web server list boxes, drop-down lists are supported with <select> controls; here, the <select> controls are drawn to display only one item in the list at a time. Here's the HTML that creates the drop-down list you see in Figure 17.5:

<select name="DropDownList1" id="DropDownList1"
onchange="__doPostBack('DropDownList1','')" language="javascript"
style="height:22px;width:144px;Z-INDEX: 101; LEFT: 160px;
POSITION: absolute; TOP: 58px">
    <option value="Item 1">Item 1</option>
    <option value="Item 2">Item 2</option>
    <option value="Item 3">Item 3</option>
    <option value="Item 4">Item 4</option>
Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor