Click to See Complete Forum and Search --> : change div id text on mouse over


andrew1234
07-31-2003, 06:18 AM
i have two links and when the mouse roles over each one

there is one piece of text on the screen that changes to match the button

eg
<a href="ssasa" onmouseover="document.getElementById('fred'="start")">start</a><br>

<a href="ssasa" onmouseover="document.getElementById('fred'="end")">end</a><br>

<div id="fred></div>

please help

thanks

Andrew

Gollum
07-31-2003, 06:30 AM
I take it it's not working...

by the looks of things, you want to change the onmouseover definition a bit...

onmouseover="document.getElementById('fred')='start';"


HTML doesn't handle nested " chars, so it's best to use only ' in your event handlers.

Charles
07-31-2003, 06:36 AM
<a href="ssasa" onmouseover="document.getElementById('fred').firstChild.data = this.firstChild.data">start</a><br>

<a href="ssasa" onmouseover="document.getElementById('fred').firstChild.data = this.firstChild.data">end</a><br>

<div id="fred">&amp;nbsp;</div>

andrew1234
07-31-2003, 06:50 AM
Hi thanks for the help

is it posible to put a table into that <div id="fred">">&nbsp;</div>

eg

<a href="ssasa" onmouseover="document.getElementById('fred').firstChild.data = '


<table width="100" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>dfgdsfg</td>
<td>sdfgsdfg</td>
</tr>
</table>


'">start</a><br>

<div id="fred">">&nbsp;</div>

thanks

andrew

Charles
07-31-2003, 06:55 AM
1) The W3C DOM way is to build up the TABLE element using document.createElement() and document.setAttribute() and such and to assign that fragment.

2) The non-standard but well supported method is to use innerHTML instead of firstChild.data.

3) But either method will give you somethig that fails when there is no JavaScript. You would do better to use HTML to draw the tables in the document and then to use JavaScript to hide or show them as you like.