Microsoft HomeproductssearchsupportshopWrite Us   Microsoft Home
Magazine
 |  Community
 |  Workshop
 |  Tools & Samples
 |  Training
 |  Site Info

Workshop  |  DHTML, HTML & CSS

SELECT Element | SELECT Object


Denotes a list box or drop-down list.

HTML Syntax

<SELECT
    ACCESSKEY=key
    ALIGN=ABSBOTTOM | ABSMIDDLE | BASELINE | BOTTOM | LEFT | MIDDLE | RIGHT | TEXTTOP | TOP
    CLASS=classname
    DATAFLD=colname
    DATASRC=#ID
    DISABLED
    ID=value
    LANG=language
    LANGUAGE=JAVASCRIPT | JSCRIPT | VBSCRIPT  | VBS 
    MULTIPLE
    NAME=name
    SIZE=n
    STYLE=css1-properties
    TABINDEX=n
    event = script
>

Members

Styles

Example

The following HTML code creates a drop-down list box. The SIZE attribute defaults to 1, so it could be omitted here.

<SELECT NAME="Cats" SIZE="1">
<OPTION VALUE="1">Calico
<OPTION VALUE="2">Tortie
<OPTION VALUE="3" SELECTED>Siamese
</SELECT>

The next example creates a multi-select list box by setting the SIZE and MULTIPLE attributes. To retrieve the selected options for a multi-select list box, iterate through the options collection checking for SELECTED set to true.

<SELECT NAME="Cars" SIZE="3" MULTIPLE>
<OPTION VALUE="1" SELECTED>BMW
<OPTION VALUE="2">PORSCHE
<OPTION VALUE="3" SELECTED>MERCEDES
</SELECT>

The following example adds a new option to the end of an existing SELECT list. In JScript (compatible with ECMA 262 language specification) and Javascript, the new Option constructor can also be used.

var oOption = document.createElement("OPTION");
oOption.text="Apples";
oOption.value="5";
document.all.oMyList.add(oOption);

See Also

OPTION, options


Does this content meet your programming needs? Write us!

Back to topBack to top

© 1998 Microsoft Corporation. All rights reserved. Terms of use.

 

Magazine Home
Ask Jane
DHTML Dude
Extreme XML
For Starters
More or Hess
Servin' It Up
Site Lights
Web Men Talking
Member Community Home
Benefits: Freebies & Discounts
Benefits: Promote Your Site
Benefits: Connect with Your Peers
Benefits at a Glance
Online Special-Interest Groups
Your Membership
SBN Stores
Join Now
Workshop Home
Essentials
Content & Component Delivery
Component Development
Data Access & Databases
Design
DHTML, HTML & CSS
Extensible Markup Language (XML)
Languages & Development Tools
Messaging & Collaboration
Networking, Protocols & Data Formats
Reusing Browser Technology
Security & Cryptography
Server Technologies
Streaming & Interactive Media
Web Content Management
Workshop Index
Tools & Samples Home
Tools
Samples, Headers, Libs
Images
Sounds
Style Sheets
Web Fonts
Training Home
SBN Live Seminars
SBN Live Chats
Courses
Peer Support
CD-ROM Training
Books & Training Kits
Certification
SBN Home
New to SBN?
What's New on SBN
Site Map
Site Search
Glossary
Write Us
About This Site