![]() |
Random image array
basically once one of the images is created randomly i want it removed from the array so it cant come up again but for some reason not all the images are appearing anyway heres what ive got whats wrong/missing?
[code]var image=new Array(); var g='.gif'; image[0]='image1'+g; image[1]='image2'+g; image[2]='image3'+g; image[3]='image4'+g; image[4]='image5'+g; var l=image.length; var buff=new Array(); for(i=0;i<l;i++){ buff[i]=new Image(); buff[i].src=image[i]; } var randomNumber=Math.floor(Math.random()*l); for(i=0;i<l;i++){ document.write('<img src="'+image[randomNumber]+'">'); image.splice(randomNumber,1); } |
Re: Random image array
If you want to display all 5 images it's easier just to do the following:
:
<script type="text/javascript"> |
Re: Random image array
If you want them to appear in a random order, for whatever reason:
:
<script type="text/javascript"> |
Re: Random image array
Ah i see now thankyou for your help.
|
| All times are GMT -5. The time now is 3:49 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC