4 Years
Discussion Span
Last Post by IIM

contacts would be the HTML element that you are gathering. I do so believe that it's from the ID=contacts, identifier.

So say for example <p id=contacts>insert stuff here</p>


getElementById returns all elements with element name attribute as specified in the double quotes.
Take a look at quote from w3.org

The getElementsByName(name) method takes a string name, and must return a live NodeList containing all the HTML elements in that document that have a name attribute whose value is equal to the name argument (in a case-sensitive manner), in tree order. When the method is invoked on a Document object again with the same argument, the user agent may return the same as the object returned by the earlier call. In other cases, a new NodeList object must be returned.

from http://www.w3.org/TR/2011/WD-html5-20110525/dom.html#dom-document-getelementsbyclassname

Edited by IIM


Contacts is our html element name ..
Your element will be like this <input type = "text" name = "contacts" />


To clarify... There are some confusing responses in this thread. The OP is asking about getElementsByName not getElementById.

document.getElementsByName() returns a HTMLCollection of all the elements with a given value for the name attribute, commonly used when targeting input elements.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.