Help Center

Local Navigation

Object: HTMLFormElement

Availability

BlackBerry® Device Software version 4.6 or later

Extends

HTMLElement

The HTMLFormElement object represents a <form> element in an HTML document.

The <form> element specifies a form that gathers information from the user. Users can submit a form by using the <submit> input element. After a submission, the form collects the names and values of enclosed <select>, <input>, and <textarea> elements and submits the query as part of the request (GET) or as post data (POST).

HTMLFormElement properties

Property name

Type

Description

Status

Availability

acceptCharset

String

Specifies a list of valid character sets for form data.

writable

4.6.0

action

String

Specifies a URI to which the form is submitted.

writable

4.6.0

elements

HTMLCollection

Returns an index of the form control elements contained within the form. Index positions begin at 0 and continue to HTMLCollection.length-1.

Image buttons (<input> elements for which type="image") are excluded from the collection.

read only

4.6.0

enctype

String

Specifies the content type the form data is encoded with.

writable

4.6.0

length

int

Returns the number of form control elements contained within the form.

read only

4.6.0

method

String

Specifies the HTTP method used to send the data to the server.

writable

4.6.0

name

String

Specifies a unique name for the form.

read only

4.6.0

target

String

Specifies where the target document is opened.

writable

4.6.0

HTMLFormElement methods

Method name

Description

Availability

item()

Returns the form control element at he specified index of the collection.

4.7.1 or later

namedItem()

Retrieves the form control element or elements whose id or name attributes that match the given name from the collection.

4.7.1 or later

reset()

Restores the default values to the form element.

4.6 or later

submit()

Submits the current values of the form element.

4.6 or later

Method: HTMLFormElement.item()

Availability

BlackBerry® Device Software version 4.7.1 or later

The item() method returns the element that is located at the specified index of the HTMLFormElement.elements collection. Image buttons (<input> elements for which type="image") are not included in the collection, and are therefore not returned with this method.

This method is equivalent to invoking HTMLFormElement.elements[ index ].

Syntax

HTMLFormElement.item( index )

Parameters

Parameter

Type

Description

index

int

Specifies the index position of the element to be returned. Valid values are from 0 and HTMLFormElement.elements-1.

Return values

This method returns the element at the indexth position in the HTMLFormElement.elements collection, or null if an invalid index position is specified.

Exceptions

None.

Method: HTMLFormElement.namedItem()

Availability

BlackBerry® Device Software version 4.7.1 or later

Syntax

The namedItem() method retrieves the element or elements that contain id or name attributes that match the specified name from the HTMLFormElement.elements collection. Image buttons (<input> elements for which type="image") are not included in the collection, and are therefore not returned with this method.

This method is equivalent to invoking HTMLFormElement.elements["name"].

HTMLFormElement.namedItem( name )

Parameters

Parameter

Type

Description

name

String

Specifies the name of the element to retrieve.

Return values

This method returns the element that has an id or name attribute of name, or null if no element with the specified name exists within the HTMLFormElement.elements collection. If multiple elements match, this method returns a NodeList object that contains all the matching elements.

Exceptions

None.

Method: HTMLFormElement.reset()

Availability

BlackBerry® Device Software version 4.6 or later

The reset() method restores the default values to the form element. This method is functionally equivalent to the user clicking a Reset button.

Syntax

HTMLFormElement.reset()

Parameters

None.

Return values

None.

Exceptions

None.

Method: HTMLFormElement.submit()

Availability

BlackBerry® Device Software version 4.6 or later

The submit() method submits the current values of the form element. This method is functionally equivalent to the user clicking a Submit button.

Syntax

HTMLFormElement.submit()

Parameters

None.

Return values

None.

Exceptions

None.


Was this information helpful? Send us your comments.