PDA

View Full Version : randomizer



geebee2008
01-12-2008, 08:10 PM
hi
i'm looking for a script that will allow me to randomize a block of code on a page. specifically, i have a page that has a div container that is set to display an image and a quote below it. i have many of these image/quote blocks for the page and i'd like to have them randomly display on visit or reload. i've done a few searches for scripts to take care of this, but haven't been able to find anything. any help would be appreciated, thanks much.

???
01-15-2008, 04:42 AM
Do you have the blocks of text/images in an array? If so you could use a random number code to pick one randomly.


Math.randomNum = function (min,max) {
var random = function (maxN) {
return Math.floor (Math.random () * maxN);
}
return random (max - min) + min;
}
That would be code for a random number. (There's probably better though)

beeps
01-15-2008, 06:55 AM
Please try the attched file

geebee2008
01-15-2008, 06:03 PM
right, i know about random image generators. so how would you change this to randomly generate blocks of images AND text? say for instance these were the blocks of code that needed to be randomly generated:

<div id="image"><img src="image1.gif" /></div>
<div class="textHd">Header Text 1</div>
<div class="textBdy">Body Text 1</div>


<div id="image"><img src="image2.gif" /></div>
<div class="textHd">Header Text 2</div>
<div class="textBdy">Body Text 2/div>

<div id="image"><img src="image3.gif" /></div>
<div class="textHd">Header Text 3</div>
<div class="textBdy">Body Text 3</div>