JavaScript Coder

javascript form name

Using JavaScript to access form objects when there are multiple forms

In order to access a form through JavaScript, we need to obtain a reference to the form object. One obvious way to approach, is to use the getElementById method. For instance, if we had a form with the id attribute "subscribe_frm", we could access the form in this way: var oForm = document.getElementById('subscribe_frm'); However, this approach has the limitation that the <form> tag must have an id attribute, as the getElementById method needs the id of an element in order to locate it in the DOM tree.

Continue Reading →