I have a JSON object similar to this
{
emp_name:'',
day1:'',
day2:'',
day3:'',
.....
dayn:''
}
I want to get this value dynamically using javascript and display it in a table. Below is what I am trying to do.
for(var i = 0; i < 2; i++)
{
var row1 = body.insertRow(i);
var name = resultset[i].emp_name;
var cell1 = row1.insertCell(0);
cell1.innerHTML=name;
cell1.setAttribute('id', 'emp_name');
for(var j = 1; j < 32; j++)
{
var cell2=row1.insertCell(j);
cell2.innerHTML = resultset[i].day + j;
}
}
But the second cell value is not getting populated. I am getting NaN
. The problem is because of day + j
. Can someone say how to approach this?