Forum Moderators: open

Message Too Old, No Replies

dynamic changing links in a table

script doesn't work properly

         

codem7

5:33 pm on May 31, 2005 (gmt 0)



okay, I have created a code that effectively dynamically changes the content in a cell of a table when hovered over links. However, I want to make it so I can dynamically change them to links, and for some odd reason, it isn't working. I'll post it below and any suggestions would be nice. Notice how the italics work, but if you stick in a <a> tag, the script fails.

<HEAD>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
var description = new Array();
description[0] = "link for first link";
description[1] = "link for second link";
description[2] = "<i>link for third link</i>";
// End -->
</script>
</HEAD>

<BODY>

<center>
<table border="0">
<tr>
<td valign=top width="160">

<a onMouseOver="Words.innerHTML = description[0];" href="link1.htm">Link 1</a><br>
<a onMouseOver="Words.innerHTML = description[1];" href="link2.htm">link 2</a><br>
<a onMouseOver="Words.innerHTML = description[2];" href="link3.htm">link 3</a>

</td>
<td width="600">
<!-- Cell with the descriptions -->
<a id="Words">- Where We Build Your Future -</a>
</td>
</tr>
</table>
</center>

whoisgregg

11:31 pm on May 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As long as I properly escape the quotes and forward slashes, your code works fine:

description[0] = "<a href=\"link1.htm\"> link for second<\/a>"; 

Does that code work for you? Perhaps this is a browser issue...