The Wayback Machine - https://web.archive.org/web/20090912182708/http://www.webreference.com:80/html/tutorial13/16.html


spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / html / tutorials / 13 / 16

index123456789101112131415161718192021exercises1

Tutorial 13: Giving Form to Forms

Developer News
Voice Search Faces Hurdles in Mobile
BlackBerry Maker RIM Buys Mobile Browser Firm
Sun, IBM Keep Flying the RISC Flag

Menu controls

A menu is a control that allows the user to select one or more choices from a list, to be included in the data submitted along with the rest of the form. To create a menu, you use the SELECT element, which contains a number of OPTION elements that define the items that the user can choose from.

The SELECT element

Context:
Can only be placed inside a FORM element.
Contents:
Can contain only OPTION elements.
Tags:
Both start-tag and end-tag are required.

Attributes for the SELECT element

NAME (Name)
The control name of the menu.
SIZE (Integer)
The number of choices visible at one time to the user.
MULTIPLE (Boolean)
If present, this attributes denotes that multiple items can be selected from the menu.
Disabled control attribute
Identifier and classification attributes
Language information attributes
Title attribute
Inline style information attribute
Tabbing navigation attribute
Intrinsic event handler attributes

The OPTION element

Context:
Can only be placed inside a SELECT or OPTGROUP element.
Contents:
Can contain only text. This text is used as the label for the menu item.
Tags:
Start-tag is required. End-tag can be implied by either the start of another OPTION element or the end of the enclosing SELECT or OPTGROUP element.

Attributes for the OPTION element

VALUE (Name)
The value used for the control if this option is selected.
LABEL (Text)
A label to be used instead of the contents of the element.
SELECTED (Boolean)
If present, this attributes denotes that the option is selected by default.
Disabled control attribute
Identifier and classification attributes
Language information attributes
Title attribute
Inline style information attribute
Intrinsic event handler attributes

A simple menu can be constructed with a syntax like the following:

<FORM ACTION="/cgi-bin/html/formdump.cgi" 
      METHOD="GET" ENCTYPE="application/x-www-form-urlencoded">
<P>Please select an operating system:
<P><SELECT NAME="platform">
<OPTION VALUE="win32">Windows 95, 98 or NT</OPTION>
<OPTION VALUE="mac">Macintosh</OPTION>
<OPTION VALUE="linux">Linux</OPTION>
</SELECT>
<INPUT TYPE="submit">
</FORM>

Please select an operating system:

A menu where the user can select more than one choice can be constructed with a syntax like the following:

<FORM ACTION="/cgi-bin/html/formdump.cgi" 
      METHOD="GET" ENCTYPE="application/x-www-form-urlencoded">
<P>Which products are you interested in?
<P><SELECT NAME="product" MULTIPLE>
<OPTION VALUE="server" SELECTED>MORONS Server</OPTION>
<OPTION VALUE="runtime" SELECTED>MORONS Run-time Application</OPTION>
<OPTION VALUE="devkit">MORONS Developer's Kit</OPTION>
</SELECT>
<INPUT TYPE="submit">
</FORM>

Which products are you interested in?

In the case of a menu with only one possible selected item, the control name will be taken from the SELECT element's NAME attribute and the value from the VALUE attribute of the OPTION element that is selected. If there are multiple selections, then multiple name/value pairs are generated, all with the same name, but with different values.

index123456789101112131415161718192021exercises1

Produced by Stephanos Piperoglou

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info
Copyright 2009 WebMediaBrands Inc. All Rights Reserved.

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
New Features in ASP.NET Ajax 4.0 · Create a File-based Blog using Jaxer · XML and PHP Simplified - Building an XML Reader
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Tips for Managing Complex Queries · The 10 Best Mobile Business Apps · xG Demonstrates True Mobile VoIP in Pilot Deployment

URL: http://www.webreference.com/html/tutorial13/16.html

Created: May 28, 1998
Revised: February 25, 1999

Morty Proxy This is a proxified and sanitized view of the page, visit original site.