473,804 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with getting nested tables

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
Nov 23 '05 #1
1 2031


Joseph Scoccimaro wrote:
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.


HTML 4 wants all table elements to have at least one explicit or
implicit tbody child element and all tr elements are then children of a
thead or tfoot or tbody but not direct children of the table itself. In
the HTML DOM a table element object has a property named tBodies which
is a collection of the explicit and implicit tbody child elements. Use
that instead of walking childNodes and looking for elements with a
certain tagName.
<http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-64060425>
You can also use the rows collection property of table or tbody or thead
or tfoot elements:
<http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-67417573>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4080
by: Dustin | last post by:
Here's what I am trying to do: (Names represent CSS classes.) I want to create a photo gallery. I want the entire gallery to be surrounded by a box named PhotoGallery. I want a fluid placement of the individual Items within PhotoGallery. An Item is a box that has two child boxes, PhotoBox and Caption. Photobox has an explicit width and height. PhotoBox contains an image whose dimensions may vary, but are constrained to be within...
0
1173
by: Mathew Relick | last post by:
I'm relatively new to this sort of thing, so forgive me if this is completely off base, but I'm having a problem getting the XMLDataDocument to do what I need it to. I have a small test application that has a DataSet with two data tables, Person and Home. I've setup Home as a child of Person. What I want to do is to load data into these two tables, and then have the data document create the xml with the child nodes (home) nested under...
8
2919
by: I am Sam | last post by:
Hi everyone, This problem is making me old. I don't want to get any older. I have a multi-nested repeater control as follows: <asp:Repeater ID="clubRep1" Runat="server"> <HeaderTemplate><table> </HeaderTemplate> <ItemTemplate>
1
2081
by: Thu | last post by:
Hi, I create a Dataset to link three tables in my Access database. E.g. The three tables are , , . I then create 2 DataRelations, 1st relation (Order_Cust_Rel) links and using CustomerID field that exists in both tables and 2nd relation (Order_Product_Rel) links and using ProductID field. I set the nested property of the relations to True so that the output will be nested. I then use WriteXML to output the dataset to a StreamWriter.
4
2902
by: perspolis | last post by:
Hi all I have a master-detail tables in sql server. I use SqlTransaction to insert data into both tables. it works well but if I check the "Cascade Delete Related Records" option in it's realtion in sql server my SqlTransaction dosen't work and get timeout error.. please help me thanks in advance
7
1755
by: . | last post by:
I'm having a display issue with my page, http://www.Gatorgrad.com, in IE6 and IE7b2. I know it's not the browser of choice, but I think the majority of windows users still use IE so I'd like to fix the problem. The issue: When the content of one of my pages extends beyond the bottom of the screen, IE places a scroll bar on the right side as it should. However, it doesn't squeeze the content to make room for it. Instead, I get a scroll...
2
2436
by: th3dude | last post by:
I am trying to pull out some nested XML using C# and XMLReader. Can't seem to extract the "Items" for each "Product" when i loop through file, i can loop over the "Product" notes just fine but everytime i perform a nested loop over the "Items" list i keep every item on the file listed for each "Product". Is there an easy approach to get the related Items for each Product ID instead of all the Items everytime?
9
5763
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just call it Express for simplicity). I have, to try to simplify things, put the exact same DB on two systems, one running MSDE and one running Express. Both have 2 Ghz processors (one Intel, one AMD), both have a decent amount of RAM (Intel system...
1
1481
by: kt | last post by:
Hi, I need to adjust the positioning of some controls at run time depending on the visibility of some panels. I am hiding and showing panels at a button click and need to adjust the positioning of the other controls accordingly. I have been trying very hard....the positioning of all the controls is relative... I have also tried using nested tables and place my columns in <tr<tdbut nothing works. after adding the tables at least the...
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10099
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3003
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.