mme Posted December 2, 2008 Share Posted December 2, 2008 Hi I have a website where the main banner changes every 3-5 seconds and loads the next image from the array below is there any way to make it automatically display the next image in sequence without having to add it into the array manually? As all my banner images are stored in mysite.com/site/banners/ and all images are jpg files with the filename as a number eg; 1.jpg ,2.jpg ect... <script type="text/javascript"> countArticle = 0; var mySlideData = new Array(); mySlideData[countArticle++] = new Array('http://mysite.com/site/banners/1.jpg','http://mysite.com/site/shop/','',''); mySlideData[countArticle++] = new Array('http://mysite.com/site/banners/2.jpg','http://mysite.com/site/shop/','Item 2 Title','Item 2 Des'); </script> Thanks Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 2, 2008 Share Posted December 2, 2008 I'm too lazy to check at the moment if JavaScript can "test" if a file exists via a URL. But, even if it did, that seems like a complex solution for something simple. You could just set a single value of the total number of banners there are. Then the script to change banners will start with 1 and keep incrementing programatically until it reaches the max number and the start over at 1 again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.