JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

Form.elements[] Property

Name

Form.elements[] Property---the input elements of the form

Availability

Navigator 2.0, Internet Explorer 3.0

Synopsis

form.elements[i]
form.elements.length

Description

form.elements is an array of the form input objects in form. The array has elements.length items in it. These items may be of any of the form input element types: Button, Checkbox, Hidden, Password, Radio, Reset, Select, Submit, Text, and Textarea. These form input objects appear in the array in the same order that they appear in the HTML source code for the form.

Usage

If an item in the form.elements[] array has been given a name with the NAME="name" attribute of its HTML <INPUT> tag, then that item's name becomes a property of form, and this property refers to the item. Thus, it is possible to refer to input objects by name instead of by number:

form.name

Usually, referring to elements by name is easier, and it is therefore a good idea to specify the NAME attribute for all form elements.

See Also

"Button", "Checkbox", "Element", "Form", "Hidden", "Password", "Radio", "Reset", "Select", "Submit", "Text", "Textarea"


Previous Home Next
Form.action Book Index Form.encoding

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell
This HTML Help has been published using the chm2web software.