Not sure if this helps with your problem, but here is a neat method I was shown to rotate images without using an index variable:
Code:
var images = [
'images/slide1.jpg',
'images/slide2.jpg',
'images/slide3.jpg'
];
function slideShowForward()
{
images.push(images.shift());
document.getElementById('images').style.backgroundImage = 'url(' + images[0] + ')';
}
function slideShowBack()
{
images.unshift(images.pop());
document.getElementById('images').style.backgroundImage = 'url(' + images[0] + ')';
}
Code:
<div id="images" style="border: 1px solid black; height: 300px;">
<div id="form">
<img src="images/prev.png" onclick="slideShowBack();" style="width: 39px; height: 34px;" />
<img src="images/next.png" onclick="slideShowForward();" style="width: 39px; height: 34px;" />
</div><!--form-->
</div><!--images-->
This code has been tested.
Bookmarks