moo Posted October 26, 2010 Share Posted October 26, 2010 I know that most things that go into this forums is for cs:s, but i need help with some javascript that i'm workin on for a friends website. Monkey, i think you like this sorta thing so this is what I have so far. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- transitional.dtd"> <html> <head> <script type="text/javascript"> function mouseOver() { document.getElementById("homepic").src ="HomeR.jpg"; } function mouseOut() { document.getElementById("homepic").src ="Home.jpg"; } function mouseOver() { document.getElementById("Gallery").src ="GalleryR.jpg"; } function mouseOut() { document.getElementById("Gallery").src ="Gallery.jpg"; } </script> </head> <body> <div align="center"> <table border="0" cellpadding="0"> <tr width="800" height="200" style="background-image: url(StevensTax.jpg)"> <td valign="bottom"> <a href="index.html"><img src="Home.jpg" border="0" id="homepic" onmouseover="mouseOver()" onmouseout="mouseOut()"></a> <a href="gallery.html"><img src="Gallery.jpg" border="0" id="Gallery" onmouseover="mouseOver()" onmouseout="mouseOut()"></a></td> </tr> <tr width="800" height="200"><td><img src="banner.jpg"></td> </tr> </table> </div> </body> </html> when I open the website it only does the second mouseover and it does it when i hover over gallery.jpg and home.jpg. I want them to be two seperate mouseovers. (btw, i couldnt figure out an easier way to space the links I hope this isnt confusing, I want two different mouseover script events, so that each time i hover over home.jpg it executes the first script for home and gallery.jpg executes gallery script. I had the id's added, but that isnt working. HALP! Quote Link to comment Share on other sites More sharing options...
Cr(+)sshair Posted October 26, 2010 Share Posted October 26, 2010 When you're declaring your mouseover function function mouseOver(){ document.getElementById("homepic").src ="HomeR.jpg"; } function mouseOut() { document.getElementById("homepic").src ="Home.jpg"; } function mouseOver() { document.getElementById("Gallery").src ="GalleryR.jpg"; } function mouseOut() { document.getElementById("Gallery").src ="Gallery.jpg"; } You're declaring mouseover and mouseout to do two things at once. Just declare them as separate functions i.e. mouseover & mouseover2, mouseout & mouseout2 Quote Link to comment Share on other sites More sharing options...
Cr(+)sshair Posted October 26, 2010 Share Posted October 26, 2010 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- transitional.dtd"> <html> <head> <script type="text/javascript"> function mouseOver() { document.getElementById("homepic").src ="HomeR.jpg"; } function mouseOut() { document.getElementById("homepic").src ="Home.jpg"; } function mouseOver2() { document.getElementById("Gallery").src ="GalleryR.jpg"; } function mouseOut2() { document.getElementById("Gallery").src ="Gallery.jpg"; } </script> </head> <body> <div align="center"> <table border="0" cellpadding="0"> <tr width="800" height="200" style="background-image: url(StevensTax.jpg)"> <td valign="bottom"> <a href="index.html"><img src="Home.jpg" border="0" id="homepic" onmouseover="mouseOver()" onmouseout="mouseOut()"></a> <a href="gallery.html"><img src="Gallery.jpg" border="0" id="Gallery" onmouseover="mouseOver2()" onmouseout="mouseOut2()"></a></td> </tr> <tr width="800" height="200"><td><img src="banner.jpg"></td> </tr> </table> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
moo Posted October 26, 2010 Author Share Posted October 26, 2010 Thanks crosshair it works Quote Link to comment Share on other sites More sharing options...
Cr(+)sshair Posted October 26, 2010 Share Posted October 26, 2010 No probs! Quote Link to comment Share on other sites More sharing options...
Guest The_Monkey Posted October 26, 2010 Share Posted October 26, 2010 What shit function names though. Those are similar to the built in functions for javascript event handlers. Name them something different. Quote Link to comment Share on other sites More sharing options...
Guest The_Monkey Posted October 26, 2010 Share Posted October 26, 2010 Also, read up on prototype or jquery. I like prototype a whole lot more than jquery, but jquery is used everywhere. They both have the same feature sets, however. Quote Link to comment Share on other sites More sharing options...
moo Posted October 26, 2010 Author Share Posted October 26, 2010 he wants it up quick so im gonna keep it as is, ill read up on that stuff later though Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.