create table with javascript dynamically

by Ramya 2009-09-30 19:53:16

Create table with javascript dynamically:

Create table with javascript dynamically.

var tab= document.createElement("table");
var sloadrow= tab.getElementsByTagName("tr");
var sloadcol=sloadrow.getElementsByTagName("td");

var inp = document.createElement("input");
inp.setAttribute("type","text");
inp.setAttribute("name","n");
inp.setAttribute("size","14");

var inp2 = document.createElement("input");
inp2.setAttribute("type","text");
inp2.setAttribute("name","v");
inp2.setAttribute("size","14");

var brk = document.createElement("br");
var tx1 = document.createTextNode("\n Test1:");
var brk = document.createElement("br");
var tx2 = document.createTextNode("\n Test2:");

var brk = document.createElement("br");
sloadcol.appendChild(tx1);
sloadcol.appendChild(inp);
sloadcol.appendChild(tx2);
sloadcol.appendChild(inp2);
sloadcol.appendChild(brk);
var tx3 = document.createTextNode("\n");
sloadcol.appendChild(tx3);

Tagged in:

1481
like
0
dislike
0
mail
flag

You must LOGIN to add comments