var index=0;
var titles=[1,2,3];
function Next()
{
if (index >= 3){index=0}
var img = document.getElementById("img1");
var imageToDisplay="../Images/img" + titles[index++] + ".jpg";
img.src=imageToDisplay;
}
So now I have decided to create the previous button using the code below. (However it does not function correctly)
function Previous()
{
if (index <= 0){index=4}
var img = document.getElementById("img1");
var imageToDisplay="../Images/img" + titles[index--] + ".jpg";
img.src=imageToDisplay;
}
Any ideas on how to make the previous button work?
This post has been edited by Dormilich: 10 December 2012 - 03:31 AM
Reason for edit:: fixed code tags

New Topic/Question
Reply


MultiQuote






|