How to use JavaScript, Ajax or jQuery to display array data in table -



How to use JavaScript, Ajax or jQuery to display array data in table -

right getting info works fine want auto display in table. have button clicked , should display result table or should create table , display way fine.

$result = array(); while ($row = mysql_fetch_assoc($res)) { $result[$i][0] = $row['fname']; $result[$i][1] = $row['lname']; $result[$i][2] = $row['membershipid']; } homecoming $result;

any help great

given info construction of

[ { fname:"john", lname:"doe", membershipid: "1234" } ]

this function should work n rows of data

function createtable(dataarray){ var table = document.createelement('table'); var tablerows = dataarray.map(function(datarow){ var tablerow = document.createelement('tr'); (var value in datarow){ var cell = document.createelement('td'); cell.innertext = datarow[value]; tablerow.appendchild(cell); } homecoming tablerow; }); (var = 0; < tablerows.length; i++){ table.appendchild(tablerows[i]); } homecoming table; }

then

var table = createtable(dataarray); document.getelementbyid('whatever dom node').appendchild(table);

javascript jquery ajax

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -