JavaScript Class

Home Help Table of Contents Class Stuff

Forms in JavaScript

Forms allow us to prompt a user for input using elements such as radio buttons, checkboxes and selection lists. Data gathered in this manner can then be posted to a server for processing. A form is created by enclosing HTML controls and other elements within <form></form> tags. A page can contain as many forms as required, but they cannot be overlapping or nested (the closing </form> tag of a form must precede the opening tag of any subsequent form).

action Property

This property specifies the URL address to which the data gathered by the form will be submitted. An email address can also be specified using the 'mailto:anybody@anywhere.com' syntax.

Syntax: object.action = URL

elements Property

This property is an array containing an object for each element on the form. These objects (checkboxes, radio buttons, etc.) are added to the array in the order that they appear in the document's source code.

Syntax: object.elements

encoding Property

This property sets the MIME type that is used to encode the data gathered by the elements in a form for submission when using the post method. This property initially contains a string reflecting the enctype attribute of the form tag, but using encoding will override this.

Syntax: object.encoding

length Property

This property returns the number of elements in a form.

Syntax: object.length

method Property

This property is a string specifying how information input in a form is submitted to the server. This should return either 'get', which is the default, or 'post'.

Syntax: object.method

name Property

This property sets or returns the name of the form. Initially contains the name attribute of the <form> tag.

Syntax: object.name

target Property

This property sets or returns the target window that responses are sent to after submission of a form.

Syntax: object.target





Home Help Table of Contents Class Stuff