HTML and CSS Reference
window , to the document , to the first form object named form1 , to its name property.
We could write document.forms.name or document.form1.name , but by using the
form object as a property of the document and the associative array notation with
its name in square brackets, it is easier to identify the object as a form object by
name if there are a number of forms on the page.
that the window is always at the top of the tree. See Figure 11.13.
with forms, all HTML elements are accessible via the DOM Level 1, the standard-
ized DOM, which all modern browsers should support. Navigating forms, images,
The getElementById() method returns a reference to the HTML element by the id
that was assigned to it on line 1. In most of the examples, the name and id are the
same, but in this example, they are different to make it clear that the id , not the
name , is used to get a reference to the element. The variable, f1 , is a reference to
the first form.
Now that we have a reference to the form, we can use it and the dot notation to
get its name.
Figure 11.13 Name those forms!