How do I get data from a data table in javascript?
This is how I accomplished reading a table in javascript. Basically I drilled down into the rows and then I was able to drill down into the individual cells for each row. This should give you an idea
var oTable = document.getElementById(‘myTable’);
//gets table
var rowLength = oTable.rows.length;
//gets rows of table
for (i = 0; i < rowLength; i++){
//loops through rows
var oCells = oTable.rows.item(i).cells;
//gets cells of current row
var cellLength = oCells.length;
for(var j = 0; j < cellLength; j++){
//loops through each cell in current row
}
}
UPDATED - TESTED SCRIPT
A1 | A2 | A3 |
B1 | B2 | B3 |
还没有评论,来说两句吧...