Friday, July 18, 2008

The select tag

The select tag can be used to either create a pull-down menu or a multiple-selection menu.
Example:
<select name="country">
<optgroup label="big_five">
<option value="india" >India</option>
<option value="usa" >USA</option>
<option value=""uk" >UK</option>
<option value="canada">Canada</option>
<option value="australia">Australia</option>
</optgroup>
<optgroup label="others">
<option value="pakistan">Pakistan</option>
<option value="france">France</option>
<option value="spain">Spain</option>
<option value="italy">Italy</option>
</optgroup>
</select>



Pull-down menu

<select name="country">
<option value="india" >India</option>
<option value="usa" >USA</option>
<opton value="uk" >UK</option>
</select>


You can organize the items of a pull-down menu using the optgroup tag.

Multiple-selection menu
The attribute multiple="multiple" makes the above code function as a multiple-selection menu.

You can set the number of items displayed using the size="x",where x is the number of items.

No comments: