this should be simple but its stumping me,
I am trying to make a slideshow that pulls random images at a random time interval (between 1 and 4 seconds). The images part works fine, and I can get the time function to create a random number, but that number doesnt change throughout the duration of the slideshow. I would like the duration to reset itself and changefor every picture that is displayed. Here is my code:
Expand|Select|Wrap|Line Numbers
- function allPlantPick(){
- setInterval("plantPick('plant1')", plantTimer());
- }
- function plantTimer() {
- var plantNum = (Math.random()*4000) + 1000;
- return(plantNum);
- }
- //this function works fine:
- function plantPick(myFoo){
- var plantChoices=["images/p1.jpg","images/p2.jpg","images/p3.jpg"];
- document.getElementById(myFoo).style.backgroundImage = "url(" + plantChoices[ Math.floor(Math.random()*plantChoices.length) ] + ")";
- }