heres some code that won't work
function setNewSrc(txt) {
document.txt.src="spainBear.gif";
}
function resetSrc(txt) {
document.txt.src="teddy.gif";
}
<img src="teddy.gif" name="teddy2" width="107" height="98" onMouseOver="setNewSrc('teddy2');" onMouseOut="resetSrc('teddy2');" />
its the parts that wont work.
im trying to make a function where you type in the name and it works with the bottom code.
thanks,
[edited by - johnnyBravo on November 15, 2003 7:52:47 AM]
javascript whats wrong with my function or calling of it?
im using javascript...
This is what youre trying to do:
However - I would do it like this:
"Stop trying to hit me and hit me!"
function setNewSrc(name) { eval("document."+name).src="spainBear.gif";}function resetSrc(name) { eval("document."+name).src="spainBear.gif";}<img src="teddy.gif" name="teddy2" width="107" height="98" onMouseOver="setNewSrc(''teddy2'');" onMouseOut="resetSrc(''teddy2'');" />
However - I would do it like this:
function setNewSrc(img) { img.src="spainBear.gif";}function resetSrc(img) { img.src="spainBear.gif";}<img src="teddy.gif" width="107" height="98" onMouseOver="setNewSrc(this);" onMouseOut="resetSrc(this);" />
"Stop trying to hit me and hit me!"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement