Här har du ett liknande exempel!
<html>
<head>
<script type="text/javascript">
var images = new Array("bild1.jpg", "bild2.jpg", "bild3.jpg", "bild4.jpg", "bild5.jpg", "bild6.jpg");
var bild;
var index = 0;
function showNext(){if(index < images.length-1)
{++index; bild.src = images[index]; }}
function showPrev(){ if(index > 0) { --index; bild.src = images[index];}}
function Visa(){bild=document.getElementById("bild"); bild.src=images[index];}
</script>
</head>
<body onload="Visa();" bgcolor=green>
<input type="button" value="Bakåt" onclick="showPrev();">
<input type="button" value="Framåt" onclick="showNext();">
<br><br>
<div>
<img src id="bild">
</div>
</body>
</html>