Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Multiple Random Pictures

    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

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,503
    Thanks
    3
    Thanked 500 Times in 487 Posts
    Code:
    <!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>

  • #3
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,503
    Thanks
    3
    Thanked 500 Times in 487 Posts
    in answer to pm to add links

    Code:
    <!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>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •