Dynamic Table

J

jainharsh

Hi Guyz,

I am trying to make a dynamic table which will automatically update
after running a query.
My Table contains 4 columns.

I am trying to update the table by adding rows of information to it.
But i am able to add only one column, how can i insert 4 columns and
make the table resize automatically.

My Function.
function getRoomDetails()
{

var table = document.getElementById('roomTable');
var row = document.createElement("tr");
var cell = document.createElement("td");
var cell2 = document.createElement("td");
var cell3 = document.createElement("td");
var cell4 = document.createElement("td");
var cellText = document.createTextNode("Column 1");
var cellText1 = document.createTextNode("Column 2");
var cellText2 = document.createTextNode("Column 3");
var cellText3 = document.createTextNode("Column 4");
cell.appendChild(cellText);
cell1.appendChild(cellText1);
cell2.appendChild(cellText2);
cell3.appendChild(cellText4);
row.appendChild(cell);
row.appendChild(cell2);
row.appendChild(cell3);
row.appendChild(cell5);
table.appendChild(row);

}

any help would be appreciated.

Thanks,
Hj
 
C

Craig Taylor

Hi Guyz,

I am trying to make a dynamic table which will automatically update
after running a query.
My Table contains 4 columns.

I am trying to update the table by adding rows of information to it.
But i am able to add only one column, how can i insert 4 columns and
make the table resize automatically.

My Function.
function getRoomDetails()
{

var table = document.getElementById('roomTable');
var row = document.createElement("tr");
var cell = document.createElement("td");
var cell2 = document.createElement("td");
var cell3 = document.createElement("td");
var cell4 = document.createElement("td");
var cellText = document.createTextNode("Column 1");
var cellText1 = document.createTextNode("Column 2");
var cellText2 = document.createTextNode("Column 3");
var cellText3 = document.createTextNode("Column 4");
cell.appendChild(cellText);
cell1.appendChild(cellText1);
cell2.appendChild(cellText2);
cell3.appendChild(cellText4);
row.appendChild(cell);
row.appendChild(cell2);
row.appendChild(cell3);
row.appendChild(cell5);
table.appendChild(row);

}any help would be appreciated.

Thanks,
Hj

Make sure you're appending the tr to either a thead or a tbody.

- Craig Taylor
http://www.ctalkobt.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top