Click to See Complete Forum and Search --> : a little problem here...


$0.05$
04-21-2003, 12:12 AM
okay, heres my code:


function change(imgName, image1, image2) {
details.src = image2;
imgName.src = image1;
}
function changeBack(imgName, image1) {
details.src = 'Images/placeholder.gif';
imgName.src = image1;
}


as you may be able to assume, i am trying to work with the onMouseOut, and onMouseOver events. The call looks similar to this:


<a href="resume.htm" onMouseOut="changeBack('Resume', 'Images/1-1.gif')"
onMouseOver="change('Resume','Images/1-2.gif','Images/resume.gif')"><img
src="Images/1-1.gif" alt="Resumé" name="Resume"
width="70" height="200" border="0"></a>


so i am supplying the functions with the image names of the files to be replaced, and the names of the current images.
The problem is that only one works, the one that has a definite name (description.src). The images with the changing names, does not work however.

I assume that its in this line: imgName.src = image1; but i am at a loss as for what else to do

I hope that my description of this problem is not too vague.

Regards,
Ryan

Nedals
04-21-2003, 12:34 AM
To do this you only need one function for both the mouseover and mouseout.

function change(imageName, img) {
document.imageName.src = img;
}

<a href="resume.htm"
onMouseOut="change('Resume', 'Images/1-1.gif')" onMouseOver="change('Resume','Images/resume.gif')">
<img src="Images/1-1.gif" alt="Resumé" name="Resume" width="70" height="200" border="0"></a>

I'm not sure what your 'Images/placeholder.gif' is doing, so there may be more to it.

$0.05$
04-21-2003, 08:47 AM
thanks a lot!

$0.05$
04-21-2003, 08:52 AM
hrmmmm

aparantly document.imgName is null, or not an object?

Nedals
04-21-2003, 11:10 PM
Ops! Try it this way...
(add the [] because imageName is a variable.)

function change(imageName, img) {
document[imageName].src = img;
}