please dont rip this site

JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

Option Object

Name

Option Object---an option in a Select box

Availability

Navigator 2.0, Internet Explorer 3.0; enhanced in Navigator 3.0

Synopsis

select.options[i]

Properties

defaultSelected

A read-only Boolean that specifies whether this option is selected by default. Set by the SELECTED attribute.

index

A read-only integer that specifies the index of this option within the array of options.

selected

A read/write Boolean that specifies whether this option is currently selected. Its initial value is specified by the SELECTED attribute.

text

The text that describes the option. It is the plain text (not formatted HTML text) that follows the <OPTION> tag. In Navigator 2.0 and Internet Explorer 3.0, this property is read-only. In Navigator 3.0 it is read/write.

value

A read/write string that specifies the value to be passed to the server if this option is selected when the form is submitted. The initial value is specified by the VALUE attribute.

Constructor

new Option([text, [value, [defaultSelected, [selected]]]])

Arguments

text

An optional string argument that specifies the text property of the Option object.

value

An optional string argument that specifies the value property of the Option object.

defaultSelected

An optional Boolean argument that specifies the defaultSelected property of the Option object.

selected

An optional Boolean argument that specifies the selected property of the Option object.

Returns

The newly created Option object.

HTML Syntax

An Option object is created by an <OPTION> tag within a <SELECT> which is itself within a <FORM>. Multiple <OPTION> tags typically appear within the <SELECT>.

<FORM ...>
  <SELECT  ...>
    <OPTION 
        [ VALUE="value" ] the value returned when the form is submitted
        [ SELECTED ] >   specifies whether this option is initially selected
    plain_text_label  the text to display for this option
        ...
  </SELECT>
        ...
</FORM>

Description

The Option object describes a single option displayed within a Select object. The properties of this object specify whether it is selected by default, whether is is currently selected, what position it has in the options[] array of its containing Select object, what text it displays, and what value it passes to the server if it is selected when the containing form is submitted.

Note that although the text displayed by this option is specified outside of the <OPTION> tag, that text must be plain, unformatted text, without any HTML tags. This is so that the text can be properly displayed in list boxes and drop-down menus that do not support HTML formatting.

You can dynamically create new Option objects for display in a Select object with the Option() constructor. Once a new Option object is created, it can be appended to the list of options in a Select object by assigning it to the variable options[options.length]. See Select.options[] for details.

See Also

"Select", "Select.options[]"


Previous Home Next
opener Book Index Option.defaultSelected

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell

file: /Techref/language/java/script/definitive/refp_283.htm, 8KB, , updated: 2019/10/14 15:00, local time: 2024/11/27 02:23,
TOP NEW HELP FIND: 
3.147.104.18:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://ecomorder.com/Techref/language/java/script/definitive/refp_283.htm"> [Chapter 21] Reference: Option</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to ecomorder.com!

 

Welcome to ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .