I want to have multiple rows for one data set using HTML table.
var row = 0;
var test = [{
food: "A",
grade: ["1", "2", "3", "5"]
},
{
food: "B",
grade: ["1", "2"]
},
{
food: "C",
grade: ["1"]
},]
var display = document.getElementById("table-body");
var newRow = display.insertRow(row);
var cell1 = newRow.insertCell(0);
var cell2 = newRow.insertCell(1);
cell1.innerHTML = test[0]["food"]
cell2.innerHTML = test[0]["grade"]
For example:
Food || Grade
---------------
A || 1
|| 2
|| 3
|| 5
---------------
B. || 1
|| 2
---------------
C. || 1
However, I'm only able to have them all listed in one cell i.e. (1,2,3,5). Any ideas on how to replicate the table above?