Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project









TAG:  option

<option> ... </option>
 
The option tag is used to insert one item in a pull-down form control. You may repeat this tag an unlimited number of times in a pull-down list. (For example, you could list all fifty states.) By default, when an item is chosen, the value that is added to the contents of the form is the text that appears immediately after the opening option tag. However, you can specify a different value by using the value attribute.
 
This tag must be placed between the opening and closing select tags. The order of the option tags determines the default order of the list. However, you can use the selected attribute to specify one item always to appear at the top of the list.
 
In general, a pull-down list should be treated as a menu. It is recommended that the text for each item in the list be short, such as one or two words. A long text can be far too unwieldy to read and will probably annoy most users.
 
The separate closing tag is mandatory.
 
Attributes and Events
 
class    dir    id    lang    onclick    ondblclick    onkeydown    onkeypress    onkeyup    onmousedown    onmousemove    onmouseout    onmouseover    onmouseup    style    title
 
disabled
The disabled attribute is a Boolean value that, if present, prevents the form control (field) from functioning. In some browsers, the control (field) will appear to be greyed out.
 
label
The label attribute is used to create a short text version of the text that appears after the opening option tag.
 
selected
The selected attribute is used to specify which one item in the pull-down will appear at the top of the list. Some browsers highlight the selected item. The default is that the list is in the same order as the option tags and there is no highlighting
 
value
The value attribute is used when you need to set a different value for the item in the pull-down that what is listed in the option tag.
 
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>DevGuru XHTML option Tag Example</title>
</head>
<body>
<select size="2">
Gold Fish
<br />
<option selected="selected">Bubble-Eye</option>
<option>Comet</option>
<option>Common</option>
<option>Oranda</option>
<option>Pearl Scale</option>
<option>Ranchu</option>
<option>Ryukin</option>
</select>

 
Output:
Gold Fish


 


Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information