Get Column Names From A Variable Using Json
I have a variable that contain all the subject names that are the column names of a table.Now i got all column names in a variable.Use this variable name in select statement. Ajax
Solution 1:
You can split and loop them like the following.
var tab = '';
var nameArray = [];
var keys = [];
for(var k in result[0]) {
keys.push(k);
}
for(var i=0;i<result.length;i++) {
tab += "<div class='col-xs-12 mrgntTB3'> <div class='row'>";
tab += "<div class='col-xs-2 blk-ht1'>";
tab += "<span class='tbRrptsstdNames'>" + result[i]["student_name"] + "</span><div>"
for(j = 1; j < keys.length; j++){
tab += "<div class='col-xs-2 blk-ht1'>";
tab += "<span class='tbRrptsstdNames'>" + result[i][keys[j]] + "</span><div>"
}
tab += "</div></div><div class='clearfix'></div> ";
}
Post a Comment for "Get Column Names From A Variable Using Json"