One advantage of referencing form objects using methods such as getElementById()
rather than the forms collection
.... is that you don't need to switch between using one syntax for referencing form objects, and another syntax for non-form objects.
In addition,
using Document object methods makes your code more flexible when you need the same code to be able to refer to both form and nonform elements. Finally, use
of the name attribute is not allowed in the strict DTD for XHTML, so if you're writing
JavaScript to work with XHTML documents, you cannot use the forms array or other
browser arrays.