?
Solved

Binding Array to a html table

Posted on 2005-03-17
2
Medium Priority
?
1,603 Views
Last Modified: 2008-03-17
I have a html table with few columns say

'Name' 'A' 'B' 'C' 'D'

I need to loop through each row of the table ,copy its contents to a javascript array which will hold the contents of all the columns of the table.
And it should work the other way round as well.
If i have an array i should be able to bind it to the table.

i used the follorwing function to loop through the table and collect its contents ,its working fine but i am getting a javscript error saying "cells is null or not an object" but i am getting the cell's contents in the alert box.
If XML can be used then also its fine.
If anybody has an idea kindly help me out

function ReadTable() {
var tbl = document.getElementById('myGrid');
var j;
            
for(j=0;j<=tbl.rows.length;j++) {
var row = tbl.rows[j];
alert(row.cells[1].innerText)
}
}

0
Comment
Question by:rajikrishna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
r_a_j_e_s_h earned 200 total points
ID: 13563666
function ReadTable() {
var tbl = document.getElementById('myGrid');
var j;
         
for(j=0;j<tbl.rows.length;j++) {
             ^------------------->change here
var row = tbl.rows[j];
alert(row.cells[1].innerText)
}
}




0
 

Author Comment

by:rajikrishna
ID: 13571525
ok how do i bind the array to the table and how to copy the contents of the table (row.cells[1].innerText) to an array??
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question