|
I'm trying to implement a script that provides two buttons with which one can click forward and backward to view a bunch of images. The image starts with a1.jpg and then as you click forward, it changes to a2.jpg, etc. For some reason, the first 3 images load fine. When I add a4.jpg to the array, it doesn't work -- I can click to the third image but not the fourth. Can anyone help me? I'm stumped! Thank you!
<img name="myPicture" src="a1.jpg">
<script language="JavaScript">
<!--
var myPix = new Array("a1.jpg","a2.jpg","a3.jpg","a4.jpg")
var thisPic = 0
function doPrevious() {
if (document.images && thisPic > 0) {
thisPic--
document.myPicture.src=myPix[thisPic]
}
}
function doNext() {
if (document.images && thisPic < 2) {
thisPic++
document.myPicture.src=myPix[thisPic]
}
}
// -->
</script>
</p>
<p><a href="javascript:doPrevious()"><img src="backward.jpg" border="none"></a><a href="javascript:doNext()"><img src="forward.jpg" border="none"></a></p>
|