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]
}
}