Tryit Editor v1.4

<html> <head> <script type="text/javascript"> myImages=new Array(); myImages[0]="w3schools.gif"; myImages[1]="bulbon.gif"; myImages[2]="landscape.jpg"; myImages[3]="w3schools.gif"; myImages[4]="bulboff.gif"; myImages[5]="smiley.gif"; imagecounter=myImages.length-1; i=0; function first() { document.getElementById('imageviewer').src=myImages[0]; i=0; } function previous() { if (i>0) { i--; document.getElementById('imageviewer').src=myImages[i]; } } function next() { if (i<imagecounter) { i++; document.getElementById('imageviewer').src=myImages[i]; } } function last() { document.getElementById('imageviewer').src=myImages[imagecounter]; i=imagecounter; } </script> </head> <body> <center> <form> <input type="button" value="First" onclick="first()"> <input type="button" value="Previous" onclick="previous()"> <input type="button" value="Next" onclick="next()"> <input type="button" value="Last" onclick="last()"> </form> <img id="imageviewer" src="w3schools.gif" alt="w3Scools" width="100" height="30" /> </center> </body> </html> | Your Result:
Edit the code above and click to see the result. | W3Schools.com - Try it yourself