Create a HTML table content in javascript and its array
by barkkathulla[ Edit ] 2014-06-18 19:00:41
<script type="text/javascript">
var list_mn;
$( document ).ready(function() {
list_mn=[
{
id : '2013',
jan : 1,
.
.
.
.
.
dec : 12,
},
{
id : '2014',
jan : 1,
.
.
.
.
.
dec : 12,
}
]
var tbl=$('<table/>').attr('id','sample_table_data');
$('#html_display_div').append(tbl);
for(var i=0;i<list_mn.length;i++)
{
if(i==0){
var tbl1='
<tr>
<th>year</th>
<th>jan</th>
.
.
.
.
<th>dec</th>
</tr>';
}
else{
var tbl1='';
}
var trf='<tr>';
for(var j=0;j<12;j++){
var td1='<td>'+list_mn[i]['id']+'</td>';
var td2='<td>'+list_mn[i]['jan']+'</td>';
var td3='<td>'+list_mn[i]['feb']+'</td>';
var td4='<td>'+list_mn[i]['mar']+'</td>';
var td5='<td>'+list_mn[i]['apr']+'</td>';
var td6='<td>'+list_mn[i]['may']+'</td>';
var td7='<td>'+list_mn[i]['jun']+'</td>';
var td8='<td>'+list_mn[i]['jul']+'</td>';
var td9='<td>'+list_mn[i]['aug']+'</td>';
var td10='<td>'+list_mn[i]['sep']+'</td>';
var td11='<td>'+list_mn[i]['oct']+'</td>';
var td12='<td>'+list_mn[i]['nov']+'</td>';
var td13='<td>'+list_mn[i]['dec']+'</td>';
}
var trl='</tr>';
$('#sample_table_data').append(tbl1+trf+td1+td2+td3+td4+td5+td6+td7+td8+td9+td10+td11+td12+td13+trl);
}
});
</script>
PRanesh
nice..
2
0
Add Reply