evo2010
-
Posts
4 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by evo2010
-
-
HiI am trying to have a number of images that appear randomly at the top of my website. The images must link to separate pages on my site. I have the following code which is working but I am getting alot of repeats, for example the first image may appear 3 or 4 times before the 3rd image appears etc. I have shortened the code to show just 3 images but I have about 15.var total_images = 3;var random_number = Math.floor((Math.random()*total_images));var random_img = new Array();random_img[0] = '<a href="page1.html"><img src="../../images/111.jpg" alt="aaa" title="test1"></a>';random_img[1] = '<a href="page2.html"><img src="../../images/222.jpg" alt="bbb" title="test2"></a>';random_img[2] = '<a href="page3.html"><img src="../../images/333.jpg" alt="ccc" title="test3"></a>';document.write(random_img[random_number]);What do I need to do to this code to ensure that none repeat until all 15 have been displayed. I want it that everytime the page is refreshed or they click through to a new page on the site the header image changes until all 15 have displayed. I also want them to be random, not 1st image, then 2nd image, then 3rd image etc....Any help is much appreciated as I'm new to javascriptThanks
Random Images with links - no repeat
in JavaScript
Posted
Thank you to all of you that have taken the time to reply, I appreciate it and I apologise for not getting in touch sooner but I have been working on another project. I now have some time to go back to this so will look into what you have all said and have a go, wish me luck! -though i'm most likely to get stuck again