The table is like this:
<table id="sample_table">
<tr>
<td>1</td>
<td><input type="text" size="5" id="in2" name="txt2" value="0"/></td>
<td><input type="text" size="5" id="in3" name="txt3" value="0"/></td>
<td><input type="text" size="5" id="in4" name="txt4" value="0"/></td>
</tr>
the js code is like this:
function export(filename) {
var csv = [];
var rows = document.getElementById('tbl_posts').querySelectorAll("table tr");
for (var i = 0; i < rows.length; i++) {
var row = [], cols = rows[i].querySelectorAll("td, th");
for (var j = 0; j < cols.length; j++){
row.push(cols[j].innerText);
}
csv.push(row.join(","));
}
// Download CSV file not posted here
downloadCSV(csv.join("\n"), filename);
}
and the export button:
<button type="button" onclick="export('myFile')">Export</button>
since it reads td not input fields it adds empty '' strings into csv list. How can I access inputs and push them into row list?