SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Trouble with multiple Java Slideshows

    Hello all I am having trouble with multiple slideshows. I have two seperate and im trying to fun them on the same interavals. The second slideshow stops.

    <script type="text/javascript">
    <!--
    var image1=new Image()
    image1.src="ciscoflash/01.jpg"
    var image2=new Image()
    image2.src="ciscoflash/02.jpg"
    var image3=new Image()
    image3.src="ciscoflash/03.jpg"
    var image4=new Image()
    image4.src="ciscoflash/04.jpg"
    var image5=new Image()
    image5.src="ciscoflash/05.jpg"
    var image6=new Image()
    image6.src="ciscoflash/06.jpg"
    var image7=new Image()
    image7.src="ciscoflash/07.jpg"
    var image8=new Image()
    image8.src="ciscoflash/08.jpg"
    var image9=new Image()
    image9.src="ciscoflash/09.jpg"
    var image10=new Image()
    image10.src="ciscoflash/10.jpg"
    var image11=new Image()
    image11.src="samsungflash/01.jpg"
    var image12=new Image()
    image12.src="samsungflash/02.jpg"
    var image13=new Image()
    image13.src="samsungflash/03.jpg"
    var image14=new Image()
    image14.src="samsungflash/04.jpg"
    var image15=new Image()
    image15.src="samsungflash/05.jpg"
    //-->
    </script>

    SLIDESHOW 1
    <img src="ciscoflash/01.jpg" width="242" height="180" id="slide" />
    <script>
    <!--
    //variable that will increment through the images
    var step=1
    function slideit(){
    //if browser does not support the image object, exit.
    if (!document.images)
    return
    document.images.slide.src=eval("image"+step+".src")
    if (step<10)
    step++
    else
    step=1
    //call function "slideit()" every 2.5 seconds
    setTimeout("slideit()",2500)
    }
    slideit()
    //-->
    </script>

    SLIDESHOW2
    <img src="samsungflash/01.jpg" width="242" height="180" id="slide2" />
    <script>
    <!--
    //variable that will increment through the images
    var step2=11
    function slideit2(){
    //if browser does not support the image object, exit.
    if (!document.images)
    return
    document.images.slide2.src=eval("image"+step2+".src")
    if (step2<16)
    step2++
    else
    step2=11
    //call function "slideit2()" every 2.5 seconds
    setTimeout("slideit2()",2500)
    }
    slideit2()
    //-->
    </script>

    Any Thoughts?

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem is here in the second slideshow ...

    Code:
    if (step2<16)
    step2++
    ... as the code sequence will (eventually) cause the browser to go looking for image16.src, which halts that script with an error.

    Make it this instead: if (step2<15) and it will work.

  3. #3
    SitePoint Member
    Join Date
    Jun 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ugh how did I miss that...Thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •