Background: I thought that I was going to end up with a dynamically created table that had the same number of <TR>
tags as entries in the JSON data.
Result: The loop is only creating one table TR and putting all the data in one row.
Below is a snippet of the loop and table creation.
var tbl = document.createElement("table");
var tblBody = document.createElement("tbody");
var row = document.createElement("tr");
var tdname = document.createElement('td');
var tddate = document.createElement('td');
var tdassigned = document.createElement('td');
for (var i in data) {
console.log("Hello world!" + i);
tdname.appendChild(document.createTextNode(data[i].name));
tddate.appendChild(document.createTextNode(data[i].date));
tdassigned.appendChild(document.createTextNode(data[i].assigned));
row.appendChild(tdname);
row.appendChild(tddate);
row.appendChild(tdassigned);
}
tblBody.appendChild(row);
tbl.appendChild(tblBody);
document.getElementById("tasklist").appendChild(tbl);
Question: Do I need to create a unique row variable for each loop?