I'm creating dynamic table and I want to display something like this:
Date Time
7:00 AM - 7:15 AM
7:15 AM - 7:30 AM
03/16/2016 7:30 AM - 7:45 AM
7:45 AM - 8:00 AM
8:00 AM - 8:15 AM
Date Time
7:00 AM - 7:15 AM
7:15 AM - 7:30 AM
05/05/2016 7:30 AM - 7:45 AM
7:45 AM - 8:00 AM
8:00 AM - 8:15 AM
Table that I'm getting looks like this:
Date Time
7:15 AM - 7:30 AM
03/16/2016 7:30 AM - 7:45 AM
7:45 AM - 8:00 AM
05/05/2016 7:00 AM - 7:15 AM
7:15 AM - 7:30 AM
7:30 AM - 7:45 AM
7:45 AM - 8:00 AM
8:00 AM - 8:15 AM
Here is my code that I use to get this table built above:
function buildTbl(){
var tbl = "<table><thead><tr><th>Date</th><th>Time</th></tr></thead>";
tbl += "<tbody>";
var count = 0;
for (var i = 0; i < dates.length; i++) {
var entries = groupedByDate[dates[i]];
tbl+= "<tr><td rowspan='"+count+"'>"+dates[i]+"</td>";
for (var j = 0; j < entries.length; j++) {
tbl+="<td>"+entries[j].Slot_Label+"</td></tr>";
count++;
}
}
tbl += "</tbody></table>";
$('#myTable').html(tbl);
}
I'm not sure in which step where I'm building my table html code is wrong? I tried to switch around and put tr tag after each output but that did not fix my problem. If anyone see what is wrong in my code please let me know. Thanks.