stevecop
12-06-2003, 09:15 PM
Hi, I'm trying to create menu that when a user clicks on "Link 1", it will highlight the link with a bgcolor of blue, while when the user clicks on "Link 2", "Link 1" will unhighlight and highlight "Link 2".
What I've been trying had got me to this:
<script language="JavaScript">
<!--
function highlight( )
{
undohighlight();
var oObj = event.srcElement;
oObj.style.color = "#FFFFFF";
oObj.style.background = "#000066";
}
function undohighlight()
{
var i
for (i = 0; i < 13; i++)
{
if(i.style.color == "#FFFFFF")
}
}
//-->
</script>
<table width="100%" border="0" cellspacing="1" cellpadding="0" class="body">
<tr>
<td><img src="http://localhost/images/pic.gif"></td>
<td><div onClick="highlight( );">Link 1</div></td>
</tr>
<tr>
<td><img src="http://localhost/images/pic.gif"></td>
<td><div onClick="highlight( );">Link 2</div></td>
</tr>
</table>
For this snippets, its working on the highlighting part, but I've no idea how to get the unhighlighting work. :(
I've done lots of search on google but no luck. Hope someone could help me here. Thanks in advanced.
What I've been trying had got me to this:
<script language="JavaScript">
<!--
function highlight( )
{
undohighlight();
var oObj = event.srcElement;
oObj.style.color = "#FFFFFF";
oObj.style.background = "#000066";
}
function undohighlight()
{
var i
for (i = 0; i < 13; i++)
{
if(i.style.color == "#FFFFFF")
}
}
//-->
</script>
<table width="100%" border="0" cellspacing="1" cellpadding="0" class="body">
<tr>
<td><img src="http://localhost/images/pic.gif"></td>
<td><div onClick="highlight( );">Link 1</div></td>
</tr>
<tr>
<td><img src="http://localhost/images/pic.gif"></td>
<td><div onClick="highlight( );">Link 2</div></td>
</tr>
</table>
For this snippets, its working on the highlighting part, but I've no idea how to get the unhighlighting work. :(
I've done lots of search on google but no luck. Hope someone could help me here. Thanks in advanced.