I have been trying PHP and it didn't work, so I changed the htaccess file and then I f'd up my server, so is there a way to do this with JavaScript? Green reps if you help me
Ok, after Googling and looking at a few sites, I found this - <script language="JavaScript"><!-- images = new Array(4); images[0] = "<img src='http://www.fpsgaming.us/images/halo_3.jpg'>"; images[1] = "<img src='http://www.computerhope.com/banners/banner2.gif'>"; images[2] = "<a href = 'http://www.computerhope.com/index.htm'><img src='http://www.computerhope.com/banners/banner3.gif' alt='Visit Computer Hope'></a>"; images[3] = "<a href = 'http://www.computerhope.com/newslet.htm'><img src='http://www.computerhope.com/banners/banner4.gif' alt='Computer Hope Newsletter'></a>"; index = Math.floor(Math.random() * images.length); document.write(images[index]); //done // --></script> Code (markup): So that's what I'm going to use.
i would still do it server-side though. What happens when you have 1000 images to randomize? Then you have to load 1000 lines of HTML just to view one image. that code above converted to php is extremely similar...
Well PHP doesn't get along with me. And I'm not going to ever have more than 10 images. Most likely I'll just stick with my 4.