T
tshad
I am trying to walk the Child nodes and am using the code:
var nodes = document.forms[0].childNodes;
alert("nodes = " + nodes + " nodes.length = " + nodes.length);
for (var i=0; i < nodes.length; ++i)
{
alert("Inside for loop - i = " + i);
alert("id: = " + nodes.id);
alert("tag: " + node.tagName);
}
alert("length = " + document.addForm.length);
From the first alert I get:
nodes = [object] nodes.length = 16
From the second alert I get:
Inside for loop - i = 0
From the 3rd alert I get:
id: = undefined
It goes no farther from here because the id is undefined.
Why is that?
What I am trying to do is find out the tag names and types as well ids
(haven't got the type there yet).
If I tak out the alert("tag... out I will get all the nodes as undefined.
What am I doing wrong here?
Thanks,
Tom
var nodes = document.forms[0].childNodes;
alert("nodes = " + nodes + " nodes.length = " + nodes.length);
for (var i=0; i < nodes.length; ++i)
{
alert("Inside for loop - i = " + i);
alert("id: = " + nodes.id);
alert("tag: " + node.tagName);
}
alert("length = " + document.addForm.length);
From the first alert I get:
nodes = [object] nodes.length = 16
From the second alert I get:
Inside for loop - i = 0
From the 3rd alert I get:
id: = undefined
It goes no farther from here because the id is undefined.
Why is that?
What I am trying to do is find out the tag names and types as well ids
(haven't got the type there yet).
If I tak out the alert("tag... out I will get all the nodes as undefined.
What am I doing wrong here?
Thanks,
Tom