Can not seem to alter table row bgcolor using DOM

T

TC

Hi

I'm trying to change the background colour of a table row when a user
puts a mouse over it or clicks on it, but for some reason the code
does not seem to work in IE 6 even though I can alter the alignment
attribute in IE 6. Heres a cut down version of the code I'm using

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function changeRowBgClick(rowID)
{

theRow = document.getElementById(rowID);

var vBgColor = theRow.getAttribute("bgcolor");
//alert(vBgColor == offColor);
if (vBgColor == "#ffffff")
{
alert("1 >"+theRow.getAttribute("bgcolor"));
theRow.setAttribute("bgcolor", "#000000");
theRow.setAttribute("align", "center");
alert("2 >"+theRow.bgcolor);
alert("3 >"+theRow.getAttribute("bgcolor"));

}
else
{
theRow.setAttribute("bgcolor",offColor);
}
alert('end of click function');

}

-->
</script>



</head>

<body>


<table border="1" width="100%">
<tr>
<td align="right" bgcolor="#ffffff" id="row<%=vID%>"
onClick="changeRowBgClick('row<%=vID%>')">
testing
</td>
</tr>
</table>
</body>
</html>

If you run this code your see that the word testing moves to the
center but in IE the background does not change, but this code works
fine in Mozilla.
I hope someone can help with this as I can't see why this would occur.




Tony Combe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top