N
Nikron
Hi,
I have dynamically generated a table in javascript on a button click
event. Each cell in the table has a style as well as a onmouseover and
onmouseout event that changes the style of that cell. My problem is it
works perfectly in FF but not in IE7. Below is the code for this,
what's wierd is that when I view the individual TD tags within IE7's
developer toolbar all the style and class attributes are there, they
just aren't shown on the screen.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.tableGRID
{
font-family:verdana;
font-size:10px;
width:100%;
border:solid 1px lightgray;
border-collapse: collapse;
}
.tbodyGRID
{
font-family:verdana;
font-size:10px;
}
.tdGRID
{
font-family:verdana;
font-size:10px;
border-right:solid 1px lightgray;
border-bottom:solid 1px lightgray;
background-color:white;
}
.tdGRIDMouseOver
{
font-family:verdana;
font-size:10px;
border-right:solid 1px lightgray;
border-bottom:solid 1px lightgray;
background-color:yellow;
cursor:hand;
}
</style>
<script language="javascript" type="text/javascript">
function BuildGrid(TargetDIV)
{
if (document.getElementById(TargetDIV))
{
var divTarget = document.getElementById(TargetDIV);
var tblGrid = document.createElement("table");
var tblBody = document.createElement("tbody");
// add the body to the grid
tblGrid.appendChild(tblBody);
// Set the style for the table
tblGrid.setAttribute("class","tableGRID")
for (var rowCount=0;rowCount < 10; rowCount++)
{
// Create a tr element
var trGrid = tblGrid.insertRow(-1); // the -1
denotes that it must add it to the end
for (var colCount=0;colCount < 20; colCount++)
{
// Create a td element
var tdGrid = trGrid.insertCell(-1); // the -1
denotes that it must add it to the end
// Set the attributes
tdGrid.setAttribute("onmouseover","javascript:this.className='tdGRIDMouseOver';");
tdGrid.setAttribute("onmouseout","javascript:this.className='tdGRID';");
tdGrid.setAttribute("class","tdGRID");
// Create the actual value of the td element
var cellValue =
document.createTextNode(rowCount + ":" + colCount);//rowCount + ":" +
colCount
// Add the actual value to the td element
tdGrid.appendChild(cellValue);
// Add the td element to the tr element
trGrid.appendChild(tdGrid);
}
// Add the tr element to the table body element
(Otherwise it won't work in IE)
tblBody.appendChild(trGrid)
}
divTarget.appendChild(tblGrid);
}
else
{
alert("The layer that the grid must be built is cannot
be found.");
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<a href="#" onclick="javascript:BuildGrid('divMyGrid');">click
here</a>
<div id="divMyGrid">
</div>
</form>
</body>
</html>
I have dynamically generated a table in javascript on a button click
event. Each cell in the table has a style as well as a onmouseover and
onmouseout event that changes the style of that cell. My problem is it
works perfectly in FF but not in IE7. Below is the code for this,
what's wierd is that when I view the individual TD tags within IE7's
developer toolbar all the style and class attributes are there, they
just aren't shown on the screen.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.tableGRID
{
font-family:verdana;
font-size:10px;
width:100%;
border:solid 1px lightgray;
border-collapse: collapse;
}
.tbodyGRID
{
font-family:verdana;
font-size:10px;
}
.tdGRID
{
font-family:verdana;
font-size:10px;
border-right:solid 1px lightgray;
border-bottom:solid 1px lightgray;
background-color:white;
}
.tdGRIDMouseOver
{
font-family:verdana;
font-size:10px;
border-right:solid 1px lightgray;
border-bottom:solid 1px lightgray;
background-color:yellow;
cursor:hand;
}
</style>
<script language="javascript" type="text/javascript">
function BuildGrid(TargetDIV)
{
if (document.getElementById(TargetDIV))
{
var divTarget = document.getElementById(TargetDIV);
var tblGrid = document.createElement("table");
var tblBody = document.createElement("tbody");
// add the body to the grid
tblGrid.appendChild(tblBody);
// Set the style for the table
tblGrid.setAttribute("class","tableGRID")
for (var rowCount=0;rowCount < 10; rowCount++)
{
// Create a tr element
var trGrid = tblGrid.insertRow(-1); // the -1
denotes that it must add it to the end
for (var colCount=0;colCount < 20; colCount++)
{
// Create a td element
var tdGrid = trGrid.insertCell(-1); // the -1
denotes that it must add it to the end
// Set the attributes
tdGrid.setAttribute("onmouseover","javascript:this.className='tdGRIDMouseOver';");
tdGrid.setAttribute("onmouseout","javascript:this.className='tdGRID';");
tdGrid.setAttribute("class","tdGRID");
// Create the actual value of the td element
var cellValue =
document.createTextNode(rowCount + ":" + colCount);//rowCount + ":" +
colCount
// Add the actual value to the td element
tdGrid.appendChild(cellValue);
// Add the td element to the tr element
trGrid.appendChild(tdGrid);
}
// Add the tr element to the table body element
(Otherwise it won't work in IE)
tblBody.appendChild(trGrid)
}
divTarget.appendChild(tblGrid);
}
else
{
alert("The layer that the grid must be built is cannot
be found.");
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<a href="#" onclick="javascript:BuildGrid('divMyGrid');">click
here</a>
<div id="divMyGrid">
</div>
</form>
</body>
</html>