HTML Help

Go Back   HTML Help Central > Site Building Central > Javascript / DHTML

Javascript / DHTML This is the place to ask questions about JavaScript and DHTML.

Register Now for FREE!
Join HTML Help Central. To sign up for your FREE account INSTANTLY fill out the form below!

Username: Password: Confirm Password: E-Mail: Confirm E-Mail:
 
Image Verification
Please enter the six letters or digits that appear in the image opposite.

  I agree to forum rules 

» Online Users: 46
2 members and 44 guests
firabladez , jordan1699
» HHC Sponsors
Closed Thread
 
Thread Tools Display Modes
  #1  
Old 11-11-2000, 02:27 PM
toggleDummy
Guest
 
Posts: n/a
Question toggle images on MouseOver

the problem:
i want an image on my website to toggle between two states everytime the user drags the mouse over it.

i've written the following script:
<script language="javascript">
<!--
var imgvec = new Array("img/img1.gif", "img/img2.gif");

function toggle(source, imgsrc1, imgsrc2)
{
if(source.src == imgvec[imgsrc1])
{
source.src = imgvec[imgsrc2];
return;
}

source.src = imgvec[imgsrc1];
}
//-->
</script>

my image-tag is like this:
<img src="img/img2.gif" onMouseOver="toggle(this, 0, 1)">

when i drag the mouse over the image the first time, it changes to img1.gif correctly. the second time i drag over the image it does not change back. the if() block is never executed...

has anyone an idea why?
  #2  
Old 01-31-2001, 11:16 AM
mkanaparthy
Guest
 
Posts: n/a
Post

I think else condition is missing
  #3  
Old 01-31-2001, 11:30 AM
Hooloovoo
Guest
 
Posts: n/a
Post

the else condidtion has nothing to do with it. This is not a JavaScript problem. You need an onMouseOut="toggle(this, 1, 0)" in your <IMG> tag.

The browser won't run your JS statement when the mouse leaves the graphic because you haven't told it to using onMouseOut. Try that and your problem should get fixed.

-K

------------------
Writing a haiku,
in seventeen syllables,
is very diffi--
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Powered by vBadvanced CMPS v3.2.0
All times are GMT -4. The time now is 06:53 PM.