...

View Full Version : Multiple Random Pictures



SageMorales
07-05-2005, 09:21 PM
anyone know of a multiple random picture displayer.
one that will display say 20 different pictures (thumbnails)
and will change positions or order next time page is loaded or refreshed?

thanks Sage

vwphillips
07-05-2005, 10:29 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<title></title>
</head>

<body onload="zxcRandomImages('ImgDisplay');" >
<div id="ImgDisplay" ></div>

<script language="JavaScript" type="text/javascript">
<!--
// by vic Phillips (05-07-2005) http://www.vicsjavascripts.org.uk

var zxcImgPath='http://www.vicsjavascripts.org.uk/StdImages/';
var zxcMyAry=new Array('Zero.gif','One.gif','Two.gif','Three.gif','Four.gif','Five.gif');


var zxcRanAry=new Array();
var zxcSRCAry=new Array();
var zxcCnt=0;

for (zxc0=0;zxc0<zxcMyAry.length;zxc0++){
zxcSRCAry[zxc0]=new Image();
zxcSRCAry[zxc0].src=zxcImgPath+zxcMyAry[zxc0];
}


function zxcRandomImages(id){
zxcId=id;
zxcRan=parseInt((zxcMyAry.length)*Math.random());
if (zxcRanAry[zxcRan]){ zxcRandomImages(zxcId); }
else {
zxcRanAry[zxcRan]=zxcMyAry[zxcRan];
zxcImg=document.createElement('IMG');
document.getElementById(zxcId).appendChild(zxcImg);
zxcImg.width=50;
zxcImg.height=50;
zxcImg.src=zxcImgPath+zxcRanAry[zxcRan];
zxcCnt++
if (zxcMyAry.length>zxcCnt){ setTimeout('zxcRandomImages(zxcId)',50); }
}
}
//-->
</script>
</body>

</html>

vwphillips
07-19-2005, 02:11 PM
in answer to pm to add links




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<title></title>
</head>

<body onload="zxcRandomImages('ImgDisplay');" >
<div id="ImgDisplay" ></div>

<script language="JavaScript" type="text/javascript">
<!--
// by vic Phillips (19-07-2005) http://www.vicsjavascripts.org.uk
// To display a number of random images, each with a specified link

var zxcImgPath='http://www.vicsjavascripts.org.uk/StdImages/';
var zxcMyAry=new Array()
zxcMyAry[0]=['Zero.gif','http://www.vicsjavascripts.org.uk'];
zxcMyAry[1]=['One.gif','http://www.codingforums.com'];
zxcMyAry[2]=['Two.gif','http://www.js-examples.com'];
zxcMyAry[3]=['Three.gif','http://www.sitepoint.com'];
zxcMyAry[4]=['Four.gif','http://www.webdeveloper.com'];
zxcMyAry[5]=['Five.gif','http://www.vicsjavascripts.org.uk'];



var zxcRanAry=new Array();
var zxcSRCAry=new Array();
var zxcCnt=0;

for (zxc0=0;zxc0<zxcMyAry.length;zxc0++){
zxcSRCAry[zxc0]=new Image();
zxcSRCAry[zxc0].src=zxcImgPath+zxcMyAry[zxc0][0];
}

function zxcRandomImages(id){
zxcId=id;
zxcRan=parseInt((zxcMyAry.length)*Math.random());
if (zxcRanAry[zxcRan]){ zxcRandomImages(zxcId); }
else {
zxcRanAry[zxcRan]=zxcMyAry[zxcRan];
zxcImg=document.createElement('IMG');
document.getElementById(zxcId).appendChild(zxcImg);
zxcImg.width=50;
zxcImg.height=50;
zxcImg.src=zxcImgPath+zxcRanAry[zxcRan][0];
zxcImg.mylink=zxcRanAry[zxcRan][1];
if (document.all){ zxcImg.style.cursor='hand'; } else { zxcImg.style.cursor='pointer'; }
zxcImg.onclick=function(){ window.top.location=this.mylink; }
zxcCnt++
if (zxcMyAry.length>zxcCnt){ setTimeout('zxcRandomImages(zxcId)',50); }
}
}
//-->
</script>
</body>

</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum