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 nestedTableAnal ysis()
{
DocBodyChildren = document.body.c hildNodes;
ParentTableTags = new Array();
i = 0;
for(j=0; j< DocBodyChildren .length; j++) {
if(DocBodyChild ren[j].nodeName.toLow erCase() == \"table\") {
ParentTableTags[i] = DocBodyChildren[j];
i++;
}//end if
}
for(k = 0; k < ParentTableTags .length; k++ ) {
childTableAnaly sis(ParentTable Tags[k].childNodes);
}
}//end nestedTableAnal ysis()
function childTableAnaly sis(NodesToChec k, tabSpace, periodSpacer)
{
j = 1;
for(i=0; i < NodesToCheck.le ngth; i++) {
document.writel n(NodesToCheck. nodeName);
if(NodesToCheck[i].nodeName == \"TABLE\") {
document.writel n(\"<p> Table Found!</p>\");
j++;
childTableAnaly sis(NodesToChec k[i].childNodes);
}//end if
if(NodesToCheck[i].nodeName == \"TR\") {
childTableAnaly sis(NodesToChec k[i].childNodes);
}
if(NodesToCheck[i].nodeName == \"TD\") {
childTableAnaly sis(NodesToChec k[i].childNodes);
}
}
}//end childTableAnaly sis
Thanks,
Joseph Scoccimaro
gt*****@mail.ga tech.edu