document.forms

JavaScript 1.0+, JScript 1.0+ Nav2+, IE 3+, Opera3+ Syntax

document.forms
document.forms[index]

Description

The forms property is an array that contains all the forms that exist within the HTML document from using the <form> tag. The forms property has one property of its own, called length, which contains the number of items in the array. The index number ranges from zero to the length minus one.

Example

Listing 7.99 accesses the names of each form using the forms[] array.

Listing 7.99 Accesses Form Names Using the forms Array
 <html> <form name="Form1"> <input type="button" value="Green" onClick = "document.bgColor='green'"> </form> <form name="Form2"> <input type="button" value="Blue" onClick = "document.bgColor='blue'"> ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.