Reason why most form javascript uses ID instead of NAME

html, javascript

Solution

The property `NAME` is not necessarily unique. For example, radio buttons are grouped by having the same name. Calling `getElementByName` would return all buttons in the set. `ID` is meant to be unique. So, to answer your question, each has their place.

Problem

Could someone go into the history/reasons why interacting with form elements using the NAME has gone out of practice and `document.getElementById` has taken over. What exactly historically happened that prompted this change and shift. And finally, has there been a shift or are both still recommended ways of doing things? ``` Document.getElementById vs document.form.name ``` According to some forum discussions document.form.name is not recognized by all browsers. Is this the case? See: ``` "I've been told in the past that you should not use "document.form_name.element_name" compared to "document.getElementById()", as the first is not recognized by all browsers. " ``` - from: http://forums.devshed.com/javascript-development-115/document-getelementbyid-vs-document-form-name-element-432059.html

Original source

Related problems