Adding Previous and Next Button Problem

Discussion in 'JavaScript' started by wd_2k6, Jan 22, 2008.

  1. #1
    Hi,

    Basically I have this script which rotates images over a certain time period. On top of this i would like a Previous and Next Button below the image, wherby if the user clicks next it goes to the next image.

    However i am not sure how to create these previous and next functions and was wondering whether somebody could please help me out, as i'm sure it's very simple?

    Here is the basic js i have for the rotating images this is fine i just need the previous and next functions if anybody could help:

    var ImageLoad = 
    [
    ['index.htm', 	'graphics/one.jpg', 		],	
    ['index.htm', 	'graphics/two.jpg', 		],	
    ['index.htm', 	'graphics/three.jpg', 	]	
    ];
    
    var ImageCount		= 3;
    var ImageDelay		= 5000;	
    var LinkTarget		= "_self"	
    var ImageIndex		= 0;
    var FirstLoad 		= 0;
    var QuickStartID 	             = 0;  	
    var htmlString 		= ""
    
    //  This function rotates the banner  //
    function ImageChange()
    {		
    htmlString = htmlString +'<a target="';
    htmlString = htmlString + LinkTarget;
    htmlString = htmlString + '" href="';
    htmlString = htmlString + ImageLoad[ImageIndex][0];
    htmlString = htmlString + '"><img border="0" height="150px" width="100%" src="';
    htmlString = htmlString + ImageLoad[ImageIndex][1];
    
    document.getElementById('MagicImage').innerHTML = htmlString; 				
    
    if(ImageIndex == ImageCount - 1)
    {		
    ImageIndex= 0;					
    }								
    else								
    {								
    ImageIndex++;							
    }								
    if(FirstLoad == 0)
    {
    SlowFinish();
    }
    }
    
    Code (markup):
     
    wd_2k6, Jan 22, 2008 IP