Help Center

Local Navigation

Object: HTMLOptionsCollection

Availability

BlackBerry® Device Software version 4.6 or later

Extends

HTMLElement

The HTMLOptionsCollection object contains an array of HTMLOptionElement objects.

You can access an individual option element within a collection by its index position using HTMLOptionsCollection.item(), by its name or id attribute using HTMLOptionsCollection.namedItem(), or you can index the object directly. For example, if you create an instance of a HTMLOptionsCollection object called myHTMLOptions, then specifying

myHTMLOptions.item(2)

myHTMLOptions.namedItem(“item”)

is equivalent to specifying

myHTMLOptions[2]

myHTMLOptions[“item”]

HTMLOptionsCollection properties

Property name

Type

Description

Status

Availability

length

int

Returns the number of HTMLOptionElement objects contained in the list.

read only

4.6 or later

HTMLOptionsCollection methods

Method name

Description

Availability

item()

Retrieves a specific option node, by index, from the collection.

4.6 or later

namedItem()

Retrieves the option node with the given name or id property value from the collection.

4.6 or later

Method: HTMLOptionsCollection.item()

Availability

BlackBerry® Device Software version 4.6 or later

The item() method returns the node at the specified index.

Syntax

HTMLOptionsCollection.item( index )

Parameters

Parameter

Type

Description

index

int

The index position of the node to be returned. Valid values are between 0 and HTMLOptionsCollection.length-1 inclusive.

Return values

Returns the node at the indexth position in the HTMLOptionsCollection array, or null if an invalid index position is specified.

Exceptions

None.

Method: HTMLOptionsCollection.namedItem()

Availability

BlackBerry® Device Software version 4.6 or later

The namedItem() method retrieves the node with the given name from the collection.

This method behaves differently depending on the document type:

  • If the document is an HTML document, this method first searches for a node with an id attribute that matches the given name, then searches for a node with a name attribute that matches the given name if no matching id attribute exists.

    When searching HTML documents, this method is case insensitive.

  • If the document is an XHTML document, this method only searches for nodes with an id attribute that matches the given name.

    When searching XHTML documents, this method is case sensitive.

Syntax

HTMLOptionsCollection.namedItem( name )

Parameters

Parameter

Type

Description

name

String

The name of the node to retrieve.

Return values

Returns the node with an id or name attribute of name, or null if no node with the given name exists.

Exceptions

None.

Method: HTMLOptionsCollection.item()

Availability

BlackBerry® Device Software version 4.6 or later

The item() method returns the node at the specified index.

Syntax

HTMLOptionsCollection.item( index )

Parameters

Parameter

Type

Description

index

int

The index position of the node to be returned. Valid values are between 0 and HTMLOptionsCollection.length-1 inclusive.

Return values

Returns the node at the indexth position in the HTMLOptionsCollection array, or null if an invalid index position is specified.

Exceptions

None.

Method: HTMLOptionsCollection.namedItem()

Availability

BlackBerry® Device Software version 4.6 or later

The namedItem() method retrieves the node with the given name from the collection.

This method behaves differently depending on the document type:

  • If the document is an HTML document, this method first searches for a node with an id attribute that matches the given name, then searches for a node with a name attribute that matches the given name if no matching id attribute exists.

    When searching HTML documents, this method is case insensitive.

  • If the document is an XHTML document, this method only searches for nodes with an id attribute that matches the given name.

    When searching XHTML documents, this method is case sensitive.

Syntax

HTMLOptionsCollection.namedItem( name )

Parameters

Parameter

Type

Description

name

String

The name of the node to retrieve.

Return values

Returns the node with an id or name attribute of name, or null if no node with the given name exists.

Exceptions

None.


Was this information helpful? Send us your comments.