J
Joseph Scoccimaro
I am currently working on a project for school dealing with accessing
the DOM. I am trying to get access to inner tables that are nested with
in other tables. Currently I am able to get all parent tables without a
problem. When I try to get an inner table through the child nodes it
says that the tr elements of the parent table are undefined. Posted is
the code I am using:
function nestedTableAnalysis()
{
DocBodyChildren = document.body.childNodes;
ParentTableTags = new Array();
i = 0;
for(j=0; j< DocBodyChildren.length; j++) {
if(DocBodyChildren[j].nodeName.toLowerCase() == \"table\") {
ParentTableTags = DocBodyChildren[j];
i++;
}//end if
}
for(k = 0; k < ParentTableTags.length; k++ ) {
childTableAnalysis(ParentTableTags[k].childNodes);
}
}//end nestedTableAnalysis()
function childTableAnalysis(NodesToCheck, tabSpace, periodSpacer)
{
j = 1;
for(i=0; i < NodesToCheck.length; i++) {
document.writeln(NodesToCheck.nodeName);
if(NodesToCheck.nodeName == \"TABLE\") {
document.writeln(\"<p> Table Found!</p>\");
j++;
childTableAnalysis(NodesToCheck.childNodes);
}//end if
if(NodesToCheck.nodeName == \"TR\") {
childTableAnalysis(NodesToCheck.childNodes);
}
if(NodesToCheck.nodeName == \"TD\") {
childTableAnalysis(NodesToCheck.childNodes);
}
}
}//end childTableAnalysis
Thanks,
Joseph Scoccimaro
(e-mail address removed)
the DOM. I am trying to get access to inner tables that are nested with
in other tables. Currently I am able to get all parent tables without a
problem. When I try to get an inner table through the child nodes it
says that the tr elements of the parent table are undefined. Posted is
the code I am using:
function nestedTableAnalysis()
{
DocBodyChildren = document.body.childNodes;
ParentTableTags = new Array();
i = 0;
for(j=0; j< DocBodyChildren.length; j++) {
if(DocBodyChildren[j].nodeName.toLowerCase() == \"table\") {
ParentTableTags = DocBodyChildren[j];
i++;
}//end if
}
for(k = 0; k < ParentTableTags.length; k++ ) {
childTableAnalysis(ParentTableTags[k].childNodes);
}
}//end nestedTableAnalysis()
function childTableAnalysis(NodesToCheck, tabSpace, periodSpacer)
{
j = 1;
for(i=0; i < NodesToCheck.length; i++) {
document.writeln(NodesToCheck.nodeName);
if(NodesToCheck.nodeName == \"TABLE\") {
document.writeln(\"<p> Table Found!</p>\");
j++;
childTableAnalysis(NodesToCheck.childNodes);
}//end if
if(NodesToCheck.nodeName == \"TR\") {
childTableAnalysis(NodesToCheck.childNodes);
}
if(NodesToCheck.nodeName == \"TD\") {
childTableAnalysis(NodesToCheck.childNodes);
}
}
}//end childTableAnalysis
Thanks,
Joseph Scoccimaro
(e-mail address removed)