Welcome to The Forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads

Javascript halp!


moo
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

<!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>

Link to comment
Share on other sites

Guest The_Monkey

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share