Greetings fellow HTML and JavaScript novice!
I've got a table with input cells in the bottom row:
<table class="convtbl" id="table1">
<tr>
<td>Distance 1 (in miles)</td>
<td>Time 1 (hh:mm:ss)</td>
<td>Distance 2 (in miles)</td>
<td>Time 2 (hh:mm:ss)</td>
</tr>
<tr>
<td><input type="text"/></td>
<td><input type="text"/></td>
<td><input type="text"/></td>
<td><input type="text"/></td>
</tr>
</table>
I'm working on a function to modify the input cell values. I haven't completed it yet, but during a trial run, I used an alert to check if text was properly extracted from column 1. Surprisingly, the alert displayed undefined
. Any thoughts on why this might be happening?
function tdconvert() {
var d1 = document.getElementById("table1").rows.item(1).cells.item(0).firstChild.textConent;
var t1 = document.getElementById("table1").rows.item(1).cells.item(1).firstChild.textConent;
var d2 = document.getElementById("table1").rows.item(1).cells.item(2).firstChild.textConent;
var t2 = document.getElementById("table1").rows.item(1).cells.item(3).firstChild.textConent;
alert(d1);
}