Dynamically construct a page with a layout of 2 grids per row and 'n' rows
I need to construct a page whose content may change based on what the user has selected. The page may have one or more grids. The grids will be layed out two in a row with 'n' rows.
My initial thoughts were to write the page using DOM. For example,
mytable = document.createElement("TABLE");
mytablebody = document.createElement("TBODY");
var mycurrent_row;
for(j=0;j<tableCnt;j++) {
if (f==0) mycurrent_row=document.createElement("TR");
mycurrent_cell=document.createElement("TD");
// currenttext=document.createTextNode("grid"+ j);
// mycurrent_cell.appendChild(currenttext);
// mycurrent_row.appendChild(mycurrent_cell);
document.write(obj);
if (f==1) {
mytablebody.appendChild(mycurrent_row);
f=0;
}
else {
f++;
}
}
But, I don't believe the document.write(obj) is correct. The result is one table per row. Is there a call to get the grid as a DOM element so I can pass it to appendChild()?
The second option was to embed javascript inside a table.
<TABLE><TR>
<TD> grid 1 </TD></TR>
<TD> grid 2 </TD></TR>
</TABLE>
But, this also produces the grids aligned vertically (one per row). I also tried putting the grid inside another table.
Does anyone have any suggestions on how I can achieve dynamically constructing a page layout as I've described?
My initial thoughts were to write the page using DOM. For example,
mytable = document.createElement("TABLE");
mytablebody = document.createElement("TBODY");
var mycurrent_row;
for(j=0;j<tableCnt;j++) {
if (f==0) mycurrent_row=document.createElement("TR");
mycurrent_cell=document.createElement("TD");
// currenttext=document.createTextNode("grid"+ j);
// mycurrent_cell.appendChild(currenttext);
// mycurrent_row.appendChild(mycurrent_cell);
document.write(obj);
if (f==1) {
mytablebody.appendChild(mycurrent_row);
f=0;
}
else {
f++;
}
}
But, I don't believe the document.write(obj) is correct. The result is one table per row. Is there a call to get the grid as a DOM element so I can pass it to appendChild()?
The second option was to embed javascript inside a table.
<TABLE><TR>
<TD> grid 1 </TD></TR>
<TD> grid 2 </TD></TR>
</TABLE>
But, this also produces the grids aligned vertically (one per row). I also tried putting the grid inside another table.
Does anyone have any suggestions on how I can achieve dynamically constructing a page layout as I've described?
Jerry
July 2,