-
accessing a DOM tree element
I have html document. In that document I have some code that looks like the
following:
<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 input
box not shown here) and presses a button on the page that says "login". The
button has onclick="login(); function. In "login()" to access what the user
entered in the input box by accessing the DOM tree. Here is what I am doing
right now.
// the login is actually a var that can contain the login
// name or password. This returns an object
var element = document.getElementById("login_name");
// child = INPUT, which it should
var 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 input
box. I can look at the DOM tree and see:
+ DIV = Name IV Type:ELEMENT_NODE Att:class=Data,id=login_name
INPUT - Name:INPUT Type:ELEMENT_NODE Att: value=bob
note that the user here types bob in thee login text area. I've tried various
ways to access this "bob" value but cannot find the correct method. I will
need to be able to read/write this text area. Should I change my actual HTML
and put XML tags around the <input type=text></input> to something like <LOGINNAME><input
type=text></input></LOGINNAME> and this will create a way to access the value
in the input box? Any help would be appreciated.
Thanks in advance,
Joe Crew
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks