View Full Version : random images: lots of them

07-28-2002, 09:46 AM

I need a script which will put 10 images into a random order of 20 images, so each image will be used twice. basically its gonna be in a 4x5 grid, so it will look something like this (but randomized, obviously):


so... like that but ranomised. If you have any ideas... then please reply :cool:

07-28-2002, 05:08 PM
name the files 1,2,3,...

w = 5; //board width
h = 4; //board height
r = 10; //number range
t = 2; //instances of each number
e = "gif"; //file extension

tb = "";
tb +='<table border="0" id="tbl" cellspacing="0" cellpadding="0" style="border-style: solid; border-color: red; border-width: 1;">';
for (y=0; y<h; y++) {
tb +='<tr>';
for (x=0; x<w; x++) {
tb +='<td><img id="'+x+"-"+y+'"></td>';
tb +='</tr>';
tb +='</table>';

imags = new Array();
for (x=0; x<r; x++) {
for (y=0; y<t; y++) {
imags[imags.length] = (x+1)+"."+e;

for (y=0; y<h; y++) {
for (x=0; x<w; x++) {
n = Math.floor(Math.random()*imags.length);
document.getElementById(x+"-"+y).src = imags[n];
imags[n] = imags[0];
t = imags.shift();


07-28-2002, 07:36 PM
nice one... thanks x_goose_x, thats perfect. :cool:

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum