PDA

View Full Version : rollover image



che_anj
Aug 3rd, 2007, 01:21 PM
This is code will work.

<a href="javascript:;"
onmouseover="note.src=add1.gif'"
onmouseout="note.src='add.gif'">
<img name="notes" border=0 src="add1.gif"></a>

But if I make it two like below it wont work anymore, could anyone tell me whats wrong with that code?

<a href="javascript:;"
onmouseover="note.src=add1.gif'"
onmouseout="note.src='add.gif'">
<img name="notes" border=0 src="add1.gif"></a>

<a href="javascript:;"
onmouseover="action.src=notes1.gif'"
onmouseout="action.src='note.gif'">
<img name="notes" border=0 src="notes1.gif"></a>


tnx

Actinia
Aug 3rd, 2007, 01:31 PM
In the code that 'works'


<a href="javascript:;"
onmouseover="note.src=add1.gif'"
onmouseout="note.src='add.gif'">
<img name="notes" border=0 src="add1.gif"></a>


You seem to have a single quote missing before add1.gif (line 2). You seem to be changing the source for something called 'note', whereas your image is called 'notes'. Does this really work for you?

John

mcjwb
Aug 3rd, 2007, 01:38 PM
Like John I strongly suspect the code you posted doesn't work and the reason the second link and image don't "work" is because you are still referencing an object called "note" which I suspect is suposed to be the image inside the link.
You need to change the name of the image inside the link.

You could also use the following code which will allways reference the image inside the link regardless of the image's name:

<a href="javascript:;"
onmouseover="this.childNodes[0].src='add1.gif'"
onmouseout="this.childNodes[0].src='add.gif'">
<img name="notes" border=0 src="add1.gif"></a>

che_anj
Aug 3rd, 2007, 01:41 PM
this is my original code

<a href="'; echo $_SERVER["PHP_SELF"]; echo '?click=actions.php&menu=3&candid='.$_GET[candid].'" "javascript:;"
onmouseover="light.src=\'images/add1.gif\'"
onmouseout="light.src=\'images/add.gif\'">
<img name="light" border=0 src="images/add.gif" alt="Insert Actions"></a>

<a href="'; echo $_SERVER["PHP_SELF"]; echo '?click=notes.php&menu=3&candid='.$_GET[candid].'" "javascript:;"
onmouseover="light.src=\'images/notes1.gif\'"
onmouseout="light.src=\'images/notes.gif\'">
<img name="light" border=0 src="images/notes.gif" alt="Insert Notes"></a>

it will work if I just make a one link, but if Im going to make it two because it wont work

mcjwb
Aug 3rd, 2007, 02:06 PM
The problem is you are creating two images both with the name "light", then when you try and reference one of the images the browser doesn't know which one you are talking about. Change the name of the second image to "light2" or something as well as changing the onmouseover and onmouseout attributes.

Or

In your links if you replace the word "light" in the onmouseover and onmouseout attributes with "this.childNodes[0]" it will work as you expect.

che_anj
Aug 3rd, 2007, 02:11 PM
oh Great , thanks a lot mcjwb,it works now..