PDA

View Full Version : Cut & Paste JavaScript Slideshow - Random Starting Point?



LifeCoach
05-09-2014, 10:20 AM
This code is working beautifully, thank you!

I would like to modify the code to randomly select just the starting point (I have over 40 image slides...).

Could you advise me please?

If this is possible that would be fantastic!

Regards

T John

jscheuer1
05-09-2014, 10:40 AM
We have no idea what script you're talking about. Do you mean:

http://www.javascriptkit.com/script/script2/jsslide.shtml

If so, just add the highlighted:


//configure the paths of the images, plus corresponding target links
slideshowimages("food1.jpg","food2.jpg","food3.jpg","food4.jpg","food5.jpg")
slideshowlinks("http://food.epicurious.com/run/recipe/view?id=13285","http://food.epicurious.com/run/recipe/view?id=10092","http://food.epicurious.com/run/recipe/view?id=100975","http://food.epicurious.com/run/recipe/view?id=2876","http://food.epicurious.com/run/recipe/view?id=20010")

//configure the speed of the slideshow, in miliseconds
var slideshowspeed=2000

var whichlink=0
var whichimage=0
whichimage = Math.floor(Math.random() * slideimages.length)
function slideit(){
if (!document.images)
return
document.images.slide.src=slideimages[whichimage].src
whichlink=whichimage
if (whichimage<slideimages.length-1)
whichimage++
else
whichimage=0
setTimeout("slideit()",slideshowspeed)
}
slideit()

LifeCoach
05-10-2014, 04:08 AM
See, I knew you'd have an idea which script I was referring to! :)

That's perfect!

Thank you so much!