M
MQ
I have been trying to insert a col tag using DOM but I can't seem to make it
work. In the following script I create a table with rows and columsn. I
tried to modify the column style, but doesn't seem to want to work. I tried
modifying the cell style and it works fine. Can anyone see what's wrong
with this code.
Thank you.
-------code-----------
<html>
<head>
<title>
</title>
<script language="Javascript">
function Table(rows, columns, id)
{
var cellAttrib;
var colAttrib;
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);
mytablebody.appendChild(myColumn);
}
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.appendChild(currenttext);
mycurrent_cell.setAttribute("id","cell_" + j + "_" + i);
mycurrent_row.appendChild(mycurrent_cell);
}
mytablebody.appendChild(mycurrent_row);
}
mytable.appendChild(mytablebody);
myLocation.appendChild(mytable);
mytable.setAttribute("border","2");
}
</script>
</head>
<body >
<div id="actionGridID">
</div>
<script language="Javascript">
<!--
var myTable = new Table(10, 5, "actionGridID");
document.all['col_1'].style.color = 'red';
-->
</script>
</body>
</html>
--
work. In the following script I create a table with rows and columsn. I
tried to modify the column style, but doesn't seem to want to work. I tried
modifying the cell style and it works fine. Can anyone see what's wrong
with this code.
Thank you.
-------code-----------
<html>
<head>
<title>
</title>
<script language="Javascript">
function Table(rows, columns, id)
{
var cellAttrib;
var colAttrib;
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);
mytablebody.appendChild(myColumn);
}
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.appendChild(currenttext);
mycurrent_cell.setAttribute("id","cell_" + j + "_" + i);
mycurrent_row.appendChild(mycurrent_cell);
}
mytablebody.appendChild(mycurrent_row);
}
mytable.appendChild(mytablebody);
myLocation.appendChild(mytable);
mytable.setAttribute("border","2");
}
</script>
</head>
<body >
<div id="actionGridID">
</div>
<script language="Javascript">
<!--
var myTable = new Table(10, 5, "actionGridID");
document.all['col_1'].style.color = 'red';
-->
</script>
</body>
</html>
--