php - How to display multiple images on random? -


I have this script that I use to display random images with hyperlinks. Can anyone tell me how can I customize it to display 5 random images at a time, preferably without repeating the same image twice?

  & lt; Script language = "JavaScript" & gt; & Lt ;! - / * Random Image Link Script - Javascript Kit (http://www.javascriptkit.com) More than 200 free javascript! Updated: 00/04/25 * / function random_imglink () {var myimages = new Array () // Specify random images below. [3] = "Data / Advertising / Advertising 1 Page" Myimages [4] = "Data / Advertisement / Advertising 3 Pages" [3] = "Data / Advertisement / ad2.png" myimages [4] = "Data / Advertisement / Ad4.png "myimages [5] =" data / ad / ad5.png "// different imagelinks = new Array () imagelinks specified link below [1] =" http: //www.javascriptkit.com " [2] = "http://www.netscape.com" Fictional Indication [3] = "http://www.microsoft.com" Fictional [4] = "http: // www .dynamicdrive.com" Fictional [ 5] = "http://www.freewarejava.com" var ry = Math.floor (Math.random () * myimages.length) if (ry == 0) write ry = 1 document ('& lt; a href = '+' "'+ Speculations [ri] +' '+' & gt; Lt; img src = "'+ myimages [ry] +' border = 0> gt; & lt; / a & gt; ')} Random_imglink () // - & gt; & Lt; / Script & gt;    

  function random_imglink () {var myimages = new Array (); ... var imagelinks = new array (); ... var usage = []; Var ry; Var howmany = 5; {Ry = Math.ceil (Math.random (* * myimages.length) for Var (i = 1; i & lt; = howmany; i ++); While (used.indexOf (ry)! = - 1) {ry = Math.ceil (Math.random () * myimages.length); } Used push [ry]; Document.write ('& lt; a href =' + '"' + imagelinks [ry] + '' + '& gt; & lt; img src ="' + myimages [ry] + 'border = 0> ; & Lt; / A & gt; ')}}   

It assumes that you are putting more images in your array than 5.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -