JS USES a for loop to iterate over the contents of all the cells in the Table
- 2020-03-30 03:44:28
- OfStack
JS traverses the contents of all the cells in the Table. The idea is to traverse all the rows in the Table, traverse each column in the Row, and get the contents of the cells in the Table
function GetInfoFromTable(tableid) {
var tableInfo = "";
var tableObj = document.getElementById(tableid);
for (var i = 0; i < tableObj.rows.length; i++) { //Traverses all rows of the Table
for (var j = 0; j < tableObj.rows[i].cells.length; j++) { //Iterate over each column in the Row
tableInfo += tableObj.rows[i].cells[j].innerText; //Gets the contents of the cells in the Table
tableInfo += " ";
}
tableInfo += "n";
}
return tableInfo;
}