Problem with table col in DOM. Please help!
I created a table using DOM, and gave every cell an id. I also included col tags in the table, and gave them id's. Now, I can easily set the styles of the cells, but I can't seem to be able to change the style of the columns. The following is the code. I hope someone knows how to fix it.
function Table(rows, columns, id)
var myLocation = document.getElementById(id);
mytable = document.createElement("TABLE");
mytablebody = document.createElement("TBODY");
for (i = 0; i < columns; i++)
myColumn = document.createElement("COL");
myColumn.setAttribute("id","col_" + i);
for(j = 0; j < rows; j++)
mycurrent_row = document.createElement("TR");
for(i = 0; i < columns; i++)
mycurrent_cell = document.createElement("TD");
currenttext = document.createTextNode("cell is row " + j + ", column " + i);
mycurrent_cell.setAttribute("id","cell_" + j + "_" + i);
// Later in the HTML coding I include the following:
// This is how I call the above function to create a table.
// Don't worry about the GridID stuff.
// This is just where I place the table.
var myTable = new Table(10, 5, "GridID");
// This is where I attempt to change the color style of the col.
// No success here!
document.all['col_1'].style.color = 'red';
Last edited by mqasem; 07-23-2004 at 11:02 PM..