accessing a DOM tree element

webmasterbeta

New Member
I have html document. In that document I have some code that looks like thefollowing:<tr><td>Name:</td><td><div class="Data" id="login_name"><input type=text></input></div></td></tr>The user enters in their login name (and their password in another inputbox not shown here) and presses a button on the page that says "login". Thebutton has onclick="login(); function. In "login()" to access what the userentered in the input box by accessing the DOM tree. Here is what I am doingright now.// the login is actually a var that can contain the login// name or password. This returns an objectvar element = document.getElementById("login_name");// child = INPUT, which it shouldvar child = element.firstChild.nodeName;[don't know what the next line here should be]What I am trying to do is access is the value a user types into the inputbox. I can look at the DOM tree and see:+ DIV = Name :DIV Type:ELEMENT_NODE Att:class=Data,id=login_nameINPUT - Name:INPUT Type:ELEMENT_NODE Att: value=http://forums.devx.com/archive/index.php/bobnote that the user here types bob in thee login text area. I've tried variousways to access this "bob" value but cannot find the correct method. I willneed to be able to read/write this text area. Should I change my actual HTMLand put XML tags around the <input type=text></input> to something like <LOGINNAME><inputtype=text></input></LOGINNAME> and this will create a way to access the valuein the input box? Any help would be appreciated.Thanks in advance,Joe Crew
 
Back
Top