Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    mtm
    mtm is offline
    Registered User
    Join Date
    Oct 2003
    Location
    US
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    slideshow help please?

    Making no headway on this.
    Have a vicious loop on the last function called previousImage()!
    I am so frustrated. The rule is I have to keep everything up to the last function that I added, as is! The only chgs to be made were manual buttons for this slideshow
    - had to take this out.

    <script language="JavaScript" type="text/javascript"><!--
    mySlideShow = setInterval("nextImage()", 2000)



    ---------------------
    Can anyone assist or point me in the right direction? I am not good at this yet...I only hope one day...
    ---------------------

    html>
    <head>
    <title>class: Creating Image Objects with a Function Call</title>
    <script language="JavaScript" type="text/javascript"><!--
    function newImg (sourceURL) {
    zImage = new Image()
    zImage.src = sourceURL
    return zImage
    }

    var currentSlide = 0

    if (document.images) {
    // if images are supported by the browser, create an array
    // of images and preload them
    slides = new Array()

    slides[0] = newImg("images/img0.jpg")
    slides[1] = newImg("images/img1.jpg")
    slides[2] = newImg("images/img2.jpg")
    slides[3] = newImg("images/img3.jpg")
    slides[4] = newImg("images/img4.jpg")
    }


    function nextImage() {

    if(document.images && document.slideshow.complete) {

    if (currentSlide == slides.length) {
    currentSlide = 0
    }
    document.slideshow.src=slides[currentSlide].src
    currentSlide++
    }
    }

    function previousImage() {

    if (document.images && document.slideshow.complete)
    {
    (currentSlide == slides.length)

    if (currentSlide == 0)
    return;


    if (currentSlide == -1)
    return;

    { document.slideshow.src=slides[currentSlide].src
    currentSlide--;

    }





    //-->
    </script>
    </head>
    <body>

    <form><table align="center" border=2>
    <tr><td><img src="images/img0.jpg" name="slideshow"
    width=290 height=265 alt="PET Slideshow"></td></tr>

    <tr><td align=center>
    <input type="button" value="<<< Previous"
    onClick="previousImage();">
    <input type="button" value="Next >>>"
    onclick="nextImage();">
    </td></tr>
    </table></form>
    //-->
    </script>
    </body>
    </html>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,151
    Thanks
    203
    Thanked 2,548 Times in 2,526 Posts
    Looks like a couple of } closing braces are missing.

  • #3
    mtm
    mtm is offline
    Registered User
    Join Date
    Oct 2003
    Location
    US
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Phillip.
    You're right! Bad braces will hurt this - that was one of the problems. This worked with the comparison of the slides.length to -1. So I added the repaired function! There was a good bit for me to learn here.
    Thanks for your input.

    Corrected Previous Image function below:



    function previousImage() {
    if (document.images && document.slideshow.complete){
    if(currentSlide == -1) {
    currentSlide = slides.length - 1
    }

    document.slideshow.src=slides[currentSlide].src
    --currentSlide

    }
    }
    Last edited by mtm; 10-25-2003 at 02:23 AM.


  •  

    Posting Permissions

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