Webwork
/
Multiple Image Randomizer

Another JavaScript randomization example, this one randomizes three separate image groups—tops, middles, bottoms—each of which has three separate photo options.

Web page:


To randomize the images click here.

Head:
<script language="javascript">
random.m=714025; random.a=4096; random.c=150889;
random.seed = (new Date()).getTime()%random.m;
function random()
{
random.seed = (random.seed*random.a + random.c) % random.m;
return random.seed / random.m;
}

function randomizeimages()
{
randomizeimage('image1', 3, 'tops/', '.png');
randomizeimage('image2', 3, 'middles/', '.png');
randomizeimage('image3', 3, 'bottoms/', '.png');
}

function randomizeimage(img, count, base, type)
{
document.images[img].src = base + Math.floor(random() * count + 1) + type
}
</script>

Body:

<div>
<img name="image1" src="tops/1.png" width="400" height="125" border="0"><br />
<img name="image2" src="middles/1.png" width="400" height="199" border="0"><br />
<img name="image3" src="bottoms/3.png" width="400" height="148" border="0"></div>
<p style="text-align: center">To randomize the images <a href="javascript:;" onClick="randomizeimages()">click here</a>.</p>

The photographs used in this demonstration are by Martin Schoeller. To view more of his work, check out:

Smithsonian/National Portrait Gallery

The New Yorker Portraiture Now Slide Show

Mediastorm Close-Up

Previous | Webwork Table of Contents | Next >
Re-Vision.com

projects:
Simple Truths (and Complex Lies)

The Built World
Semblance Portrait Project
Back to Square One
Changing Chicago
Chicago's Reliance Building
US
Along the Mississippi River
The Work of Antoni Gaudí
Graffiti

places:
Morocco 2023
Beecher, Illinois
Iceland 2017
Cuba 2015
Providence, Rhode Island
Greece 2013
Eastern Europe 2013
Israel 2010
Paris, France
Puebla, Mexico 2009
Puerto Rico 2009
Barcelona 2007
Rome, Italy 2006

archive:
Graphics, sounds, and other ancient
items from the dawn of the Web.


FWIW:
Biography

©
Jay Boersma