[Javascript] Selecting a form element

Triche Osborne wdlists at triche-osborne.com
Wed Oct 4 08:47:48 CDT 2006


Terry Riegel wrote:
> If I have a form element like
> 
> <input type="text" name="mydata">
> 
> Is there a way to select it in a similar manner to getElemntById()?

var nameArray = document.getElementsByTagName('mydata');

Providing you've used unique names, nameArray[0] should yield the 
element you're looking for. (You should test nameArray.length to be 
sure, however, before just grabbing nameArray[0].)

Triche




More information about the Javascript mailing list