Jump to content

Automatic Array's ?


mme

Recommended Posts

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

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.