473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Cycling through table cells

Hey, I'm not as familiar with JavaScript as I'd like to be so I need a little bit of help with a problem I've got. I've got a table that I need to cycle through and gather what is on the inside of each cell, and store them into something like an array.

The table has an undetermined amount of rows (they can be created by the user) but it has 8 cells within each row I need to get the contents out of. I'd like to put it all into an array, something like this:

Expand|Select|Wrap|Line Numbers
  1. var aVariable = new Array();
  2. aVariable[0] = "/boot|ext3|1234|no|no|-|-|-";
Then I need to take each string in the array and break it apart. I don't really need help with this, I've got that figured out, but I just can't figure out how to cycle through the table rows and cells to put the information into the array. So far I've come up with something like this:

Expand|Select|Wrap|Line Numbers
  1. for (var x = 1; x < totalHD; x++) {
  2.         var theTableID = document.getElementById("hdpart-" + x);
  3.         var theTableRow = theTableID.tBodies[0].getElementsByTagName("tr");
  4.         var theTableCell = theTableID.tBodies[0].theTableRow.getElementsByTagName("td");
  5.  
  6.  
  7.  
  8.     }
totalHD is the number of tables, then within those tables it needs to go through each row and collect the information from each cell. If anyone has any suggestions, I'd really appreciate any help. Thanks!
Oct 3 '07 #1
3 1590
gits
5,390 Expert Mod 4TB
hi ...

getElementsByTagName returns a node list so you have to loop through the table rows and retrieve the table-cells for every row. now loop through the cells and retrieve the needed values ... you may push them into arrays or use an object as a table-values list. when you have parsed all tables you may calculate with the retrieved values or whatever ... you may do the calculation even during parsing ...

kind regards
Oct 3 '07 #2
Got it! Pretty simple, I just make it a lot harder for some reason. Thanks!
Oct 3 '07 #3
gits
5,390 Expert Mod 4TB
hi ...

glad to hear you got it working ... post back to the forum anytime you have more questions ...

kind regards
Oct 3 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Sugapablo | last post by:
Can anyone help me out with some code to change three table cells (<td>) when one is hovered over? I have a calendar grid where each day is made up of three table cells and I want all three to...
4
by: jeffsal | last post by:
I am using sorttable.js to sort a table which works fine which allows a user to sort the table by clicking on the column header. Is there some code I could add to the page (onload or something) to...
1
by: cotton_gear | last post by:
Hello, Fiest of all let me thank this group for so quick in responding to any postings. I am using a javascript based utility from a site to sort the columns of the table. But, for some strange...
5
by: -:= Cactus | last post by:
Hi! I've made a form for dataentry in a simple table. However when there are records in that table and I open the form it only displays the new (blank) record. The total number of records is 1,...
7
by: Shawn B. | last post by:
Greetings, I am trying to create a table that has a scrolling body. The problem I'm experiencing is that if the columns in the "body" part of the table exceed the width of the "header" then...
7
by: Kamal | last post by:
Hello all, I have a very simple html table with collapsible rows and sorting capabilities. The collapsible row is hidden with css rule (display:none). When one clicks in the left of the...
6
by: Romulo NF | last post by:
Greetings again to everyone, Im back to show this grid componenet i´ve developed. With this grid you can show the data like a normal table, remove the rows that you need, add rows, import data,...
5
by: Romulo NF | last post by:
Greetings, I´m back here to show the new version of the drag & drop table columns (original script ). I´ve found some issues with the old script, specially when trying to use 2 tables with...
5
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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,...
0
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...

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.