SlideShow – User Enters Forward or Backward

[Total: 0    Average: 0/5]

This shows how to have an HTML file use javascript to rotate through a selection of pictures on the event of a form button being selected to go forward or backward.

Body Code:

<script type=text/javascript>
var current = 0;
var myPics = new Array();
function addPic(_p) {
  myPics[myPics.length?myPics.length:0] = new Image();


function checkIt(val) {
  current = Math.abs((current+parseInt(val))%myPics.length);
  document.myimg.src = myPics[current].src;

<br><input type=button value="-" onclick="checkIt(-1)">
<script type=text/javascript>
document.write("<img name=myimg alt='' src='"+myPics[current].src+"'>");
<input type=button value="+" onclick="checkIt(1)">

Times Viewed: 11

Leave a Reply

Your email address will not be published. Required fields are marked *