Don't forget to name forms for JavaScript

While for most elements, the Name attribute has been deprecated in favor of the ID attribute, Netscape Navigator and IE still require you to Name your forms if you want to specify them by name in JavaScript.

For instance, given the following

JavaScriptdocument.myForm.elements['textbox'].value

You must provide the following XHTML:





Of course, the ID attribute alone works just fine for any other syntax, such as:

document.forms["myForm"]

and obviously the getElementById() function also works with form tags that don't have a Name attribute.

Source: Mike D. Jones, MCP, BCIP
Viewed 3668 times