How to Generate 3x3 HTML Table From an JavaScript Array -
i have array of values in javascript follows:
var data = {"a", "b", "c", "d", "e", "f", "g", "h", "i" };
how can generate 3x3 html table following
a b c d e f g h
var data = ["a", "b", "c", "d", "e", "f", "g", "h", "i" ]; // corrected array syntax var table = document.createelement("table"); var = 0; (var r = 0; r < 3; r++) { var row = table.insertrow(-1); (var c = 0; c < 3; c++) { var cell = row.insertcell(-1); cell.appendchild(document.createtextnode(data[i++])); } } document.body.appendchild(table);
Comments
Post a Comment