Basically my query is i want to have multiple image rollovers working so below is the code where i have 3 images but when i click on the image on web it only shows me 2nd picture but doesnt show 3rd picture.
I want when i do a mouse over on the image it should starts to change again and again until i remove the mouse from the image.
Below is my some sample code.
I would be grateful if somebody help me out.
Code:
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
Rollimage = new Array()
Rollimage[0]= new Image(121,153)
Rollimage[0].src = "car1.jpg"
Rollimage[1] = new Image(121,153)
Rollimage[1].src = "car2.jpg"
Rollimage[2] = new Image(121,153)
Rollimage[2].src = "car3.jpg"
function SwapOut(){
for (i=0; i< Rollimage.length; i++)
{
document.Rupert.src = Rollimage[i].src;
}
i++;
return true;
}
function SwapBack(){
document.Rupert.src = Rollimage[0].src;
return true;
}
</SCRIPT>
</HEAD>
<BODY>
<IMG SRC="car1.jpg"
NAME="Rupert"
WIDTH=121
HEIGHT=153
BORDER=0 onmouseover="SwapOut()"
onmouseout="SwapBack()">
</A>
</P>
<p>test</p>
</BODY>
</HTML>
1. What are the parameters after the new Image() assignment for?
If they are to define the width and height, this is not the way to do it.
You syntax creates an Array with 121x151 elements, which never get assigned!
2. Why the extra i++ at the end of the 'SwapOut()' function?
As far as I can see it is not used anywhere.
Also, try putting a temporary 'alert(msg)' in the loop to make sure
that the image assignment is correct and that it is not happening
so fast that you cannot see the change occur.
3. I don't understand the reference to the 'on click' in the first sentence.
You only check for 'onMouseOver=' and 'onMouseOut=' to occur, not 'onClick='.
1. Each Picture will have its own selection of images
2. I want to stop the rotation once mouse is removed from any image and if i hover on any image it should be the only one start rotating
example will be lets say:
many different designs of dresses on webpage and when u click any small image it starts rotating to different images for that specific design
Again i am really thankful for your continue help...
Unfortunately, well for you anyway, I am off to play a round of golf now, so I will not be able to look at this problem until this evening.
Of course, if you are lucky, someone else may solve it for you, in the meantime.
PERFECTTTTTOOOO Thanks a million..It worked...You are a great life saver..
I will try to understand some of the tags in java script but can u please tell me..
1. why '#' with container and myimage?
2. what does that means : onmouseover=function() ?
3. Can you please small bit tell me what is going on in rotateImage(obj,ary) function?
can u please tell me..
1. why '#' with container and myimage?
2. what does that means : onmouseover=function() ?
3. Can you please small bit tell me what is going on in rotateImage(obj,ary) function?
[translation] I need to pass this off as my own work when my teacher asks me to explain it.
Where used, return should be executed unconditionally and always as the last statement in the function.
That's my signature, it's not part of the damn post!
Instead of setting the onmouseover event handler as an attribute of the img element,
it has been set in the javascript itself.
This has the advantage of leaving the markup tidier and quicker to load.
3. Can you please small bit tell me what is going on in rotateImage(obj,ary) function?
The parameter obj refers to the element that has the mouseover.
The parameter ary refers to the array of images to be used.
Bookmarks