# Setting a random time interval for a slideshow?

**URL:** <https://forum.kirupa.com/t/setting-a-random-time-interval-for-a-slideshow/235677>\
**Category:** Uncategorized\
**Created:** [August 14, 2007, 12:21am UTC](https://forum.kirupa.com/t/setting-a-random-time-interval-for-a-slideshow/235677 "2007-08-14T00:21:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![newsteve](https://avatars.discourse-cdn.com/v4/letter/n/5f8ce5/32.png) [@newsteve](https://forum.kirupa.com/u/newsteve)\
**Post date:** [August 14, 2007, 12:21am UTC](https://forum.kirupa.com/t/setting-a-random-time-interval-for-a-slideshow/235677/1 "2007-08-14T00:21:44Z")

</div>

hi,

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:

```auto
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)] + ")";
}

```
