...

View Full Version : randomising images in a table



baz7621
03-11-2004, 05:33 PM
Hiya

I have a 4x4 table and i have 16 set images to appear in each of the cells. How do i code a function so that the images appear in a randomise fashion when a button on the website is clicked

Vladdy
03-11-2004, 05:49 PM
Array.prototype.swap = function(index1,index2)
{ var temp = this[index1];
this[index1] = this[index2];
this[index2] = temp;
return;
}

Array.prototype.shuffle = function()
{ for(var i=0; i<this.length; i++)
{ ind1 = Math.floor(Math.random()*this.length);
ind2 = Math.floor(Math.random()*this.length);
this.swap(ind1,ind2);
}
return;
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum