View Full Version : Random graphic with a twist - help please

03-26-2005, 02:10 PM
I would like to have my header graphic change randomly, without ssi. Doing a search of the forums, I found this post:

That script, shown below, is exactly what I need BUT, I need to modify it and I am not sure how. My header graphic is quite large and I want to slice it up into several peices. How can I load a random header when the header is broken into several smaller graphics - I need the 4 peices to all match!

<script language="JavaScript" type="text/javascript">
// This script was supplied free by Hypergurl
// http://www.h y p e r g u r l .com remove the spaces
// JavaScript to interpolate random images into a page.
var ic = 6; // Number of alternative images
var xoxo = new Array(ic); // Array to hold filenames

xoxo[0] = "http://www.yoursite.com/graphic1.gif";
xoxo[1] = "http://www.yoursite.com/graphic2.gif";
xoxo[2] = "http://www.yoursite.com/graphic3.gif";
xoxo[3] = "http://www.yoursite.com/graphic4.gif";
xoxo[4] = "http://www.yoursite.com/graphic5.gif";
xoxo[5] = "http://www.yoursite.com/graphic6.gif";

function pickRandom(range) {
if (Math.random)
return Math.round(Math.random() * (range-1));
else {
var now = new Date();
return (now.getTime() / 1000) % range;
// Write out an IMG tag, using a randomly-chosen image name.
var choice = pickRandom(ic);
// -->

<SCRIPT LANGUAGE="JavaScript">document.writeln('<TD'+'><IMG SRC="'+xoxo[choice]+'" HEIGHT=184 WIDTH=120 BORDER=0 ><'+'/TD>');</SCRIPT>

Any help would be appreciated,


03-26-2005, 03:17 PM


<script language="JavaScript" type="text/javascript">
// by Vic Phillips http://www.vicsjavascripts.org.uk

var ImgPath='http://www.vicsjavascripts.org.uk/StdImages/';

var ImgAry = new Array(); // Array to hold filenames
ImgAry[0] = ['Zero.gif','One.gif','Two.gif'];
ImgAry[1] = ['One.gif','Two.gif','Three.gif'];
ImgAry[2] = ['Two.gif','Three.gif','Four.gif'];
ImgAry[3] = ['Three.gif','Four.gif','Five.gif'];


function LoadDisplay(){
for (i=0;i<3;i++){

// -->

<body onload="LoadDisplay();" >

<img id="MyImg0" src="Blank.gif" width="50" height="50"><img id="MyImg1" src="Blank.gif" width="50" height="50"><img id="MyImg2" src="Blank.gif" width="50" height="50">