468,110 Members | 1,827 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,110 developers. It's quick & easy.

Dynamic Table

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

Jan 25 '07 #1
2 4423


On Jan 25, 3:01 pm, "jainharsh" <jain.perso...@gmail.comwrote:
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

Jan 25 '07 #2
jainharsh wrote :
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.
Then do not set the table width otherwise you will be over-constraining
the table.
And as mentioned by Craig, append the table rows to a table section
(thead or tbody) because IE 6+ has a known bug on this.

Dynamically creating, populating and inserting a table
http://www.gtalbot.org/DHTMLSection/CreatingTable.html

Gérard
--
Using Web Standards in your Web Pages (Updated Dec. 2006)
http://developer.mozilla.org/en/docs...your_Web_Pages
Jan 25 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Ina Schmitz | last post: by
1 post views Thread by Nathan Bloomfield | last post: by
3 posts views Thread by CAD Fiend | last post: by
7 posts views Thread by Abraham Luna | last post: by
reply views Thread by Eniac | last post: by
6 posts views Thread by =?ISO-8859-1?Q?Tim_B=FCthe?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.