SeanT wrote:
I can't seem to get the value associated with an attribute I created
on a table row called "BackColor" . I can get the length without
issue, but whenever I try the value I get nothing.
Thanks in advance,
Sean
<-- Begin Script -->
var lastColorUsed;
function fnChangeBackCol or(row, highlight)
{
if (highlight)
{
lastColorUsed = row.style.backg roundColor;
row.style.backg roundColor = '#dcdfff';
}
else
{
alert(row.BackC olor.length); //this returns the value '7'
row.style.backg roundColor = row.BackColor.v alue;
row.style.backg roundColor = row.BackColor;
However, the reading of "expando" properties is only something IE can
do, this code will not reset the background color in Gecko-based
browsers.
}
}
<-- End Script -->
<-- Begin HTML -->
<tr onmouseover="ja vascript:fnChan geBackColor(thi s,true);"
onmouseout="jav ascript:fnChang eBackColor(this ,false);"
onclick="javasc ript:fnRowClick (this);" BackColor="#fff fff">
<!-- End HTML -->
A better approach is to remember the current background color yourself
in code. You also don't need "javascript :" in every event handler:
<script type="text/javascript">
function fnChangeBackCol or(row, highlight) {
if (highlight) {
row.defaultBack groundColor = row.style.backg roundColor;
row.style.backg roundColor = '#dcdfff';
} else {
row.style.backg roundColor = row.defaultBack groundColor;
}
}
</script>
<table>
<tr onmouseover="fn ChangeBackColor (this,true);"
onmouseout="fnC hangeBackColor( this,false);"
onclick="fnRowC lick(this);">
<td>TEST</td>
</tr>
</table>
Above code tested and working in IE 6SP1, Mozilla Firefox 1.0PR and
Opera 7.54.
--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ -
http://jibbering.com/faq