I can't believe how long this has taken me but I can't seem to figure out how to extract a cell value from an HTML table as I iterate through the table with JavaScript. I am using the following to iterate:
  var refTab=document.getElementById("ddReferences")   var  ttl;   // Loop through all rows and columns of the table and popup alert with the value   // /content of each cell.   for ( var i = 0; row = refTab.rows[i]; i++ ) {      row = refTab.rows[i];      for ( var j = 0; col = row.cells[j]; j++ ) {         alert(col.firstChild.nodeValue);      }   }   What is the correct call I should be putting in to the alert() call to display the contents of each cell of my HTML table? This should be in JS...can't use jQuery.
var t = document. getElementById("table"), d = t. getElementsByTagName("tr"), r = d. getElementsByTagName("td");
each(function() { valuesByRowID[this.id] = $(this). find("> td"). map(function() { // Option 1: Getting the value of the `value` attribute: return this. getAttribute("value"); // or return $(this).
$('#mytable tr'). each(function() { var customerId = $(this). find("td:first"). html(); });
function GetCellValues() {     var table = document.getElementById('mytable');     for (var r = 0, n = table.rows.length; r < n; r++) {         for (var c = 0, m = table.rows[r].cells.length; c < m; c++) {             alert(table.rows[r].cells[c].innerHTML);         }     } } 
                        If I understand your question correctly, you are looking for innerHTML:
alert(col.firstChild.innerHTML); 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With