You could use setInterval() instead, that way your function
would be
executed in an interval, rather than after a timeout. To
make the
second picture rotate after the first one, I'd call the
randPic2()
from within the first picture and with a timeout. that way
your first
picture controls your second picture.
On Feb 13, 6:30 pm, "Newbie" <nikki_herr... comcast.net> wrote:
> I am using setTimeout( ) to continuously call a
function that randomly
> rotates/displays 2 images on a page. The part I need
help with is the
> second image should rotate 3 seconds after the first
image rotates. I
> cannot figure out how to accomplish the 3 second delay.
My code is
> pasted below:
>
> function randPic(){
> randPic1();
> randPic2();
>
> }
>
> function randPic1(){
> picIndex = picIndex + 1;
> if (picIndex>=middlepics.length)
> picIndex = 0;
>
d.images["pic1"].src="images/middle/"+mi
ddlepics[picIndex];
>
d.images["pic1"].alt=middlealts[picIndex];
>
>
timerID=setTimeout("randPic1()",3700);
>
> }
>
> function randPic2(){
> bottomPicIndex = bottomPicIndex + 1;
> if (bottomPicIndex>=bottompics.length)
> bottomPicIndex = 0;
> d.images["pic2"].src="images/
> bottom/"+bottompics[bottomPicIndex];
>
d.images["pic2"].alt=bottomalts[bottomPicIndex];
>
>
timerID=setTimeout("randPic2()",5500);
>
> }
>
> The randPic( ) function is called in the onLoad event
of the body tag.
> Any ideas you may have would be greatly appreciated.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "JavaScript Forum" group.
To post to this group, send email to
JavaScript-Information googlegroups.com
To unsubscribe from this group, send email to
JavaScript-Information-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/JavaScript-Information
?hl=en
-~----------~----~----~----~------~----~------~--~---
|