rajikrishna
asked on
Binding Array to a html table
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('m yGrid');
var j;
for(j=0;j<=tbl.rows.length ;j++) {
var row = tbl.rows[j];
alert(row.cells[1].innerTe xt)
}
}
'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('m
var j;
for(j=0;j<=tbl.rows.length
var row = tbl.rows[j];
alert(row.cells[1].innerTe
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER