2

I am trying to make a simple slideshow of 3 pictures in JS.

I wrote the following code in the <head> code </head>, but it is not working.

The problem, I suspect, is to do with the brackets. However, as far as I can see, the brackets all match up.

But say I delete the last two } brackets, and then re add them, when I type in the first one, it says mismatched bracket, then when I type the second one, it matches up to the { bracket beside my function line.

Here is the code. I have created forward and backward buttons in the body of my site which call the function, and those appear on my site, but when I click the buttons, nothing happens, probably due to the bracket problem which I can't figure out.

Above the function line, I included the title, the script tags for JS, and made an array called Pictures with three pictures in it (the pics did not end in Jpg, which might be a problem??).

I then set the array to 0.

function RunSlideShow(ForwardBack){                                                                                                       

    if  (document.images){                                                                                                              
        CurrentPicture = CurrentPicture + ForwardBack                                                                                   
        if (CurrentPicture > (Pictures.length-1) )    {                                                                                 
            CurrentPicture=0                                                                                                            
        }                                                                                                                               
        if(CurrentPicture< 0){                                                                                                          
            CurrentPicture=Pictures.length-1                                                                                            
        }                                                                                                                               

        document.PictureDisplay.src=Pictures[CurrentPicture]                                                                            
    }
} 
MasterAM
  • 16,283
  • 6
  • 45
  • 66
  • You should probably add some more code, as the part you included tells very little. You might consider compiling a jsFiddle or linking to a live example. – MasterAM Jul 21 '13 at 19:54
  • Have you placed it inside script tags? Something like: – Vinícius Gobbo A. de Oliveira Jul 21 '13 at 20:32
  • Your syntax in terms of opening/closing brackets is correct here, the missing bracket issue is most likely coming from a closure higher up in your script. Could you try and post a fiddle with the big picture? – Ken Aug 02 '13 at 00:17
  • Also, you should try to end your lines with semicolons ";". You might try looking at this post. http://stackoverflow.com/questions/10752383/javascript-for-slideshow – abalter Nov 25 '13 at 04:57

0 Answers0