robbyirish Posted September 29, 2009 Share Posted September 29, 2009 I need some help customising this code.. i know very little about javascript so im hoping you guys can help me out. this script displays a random image with a link, i've customised it so it displays the text at the bottom of the image as well by adding a new variable and including it in the document.write function the problem i have is i have no idea how to make this script display more than one image at a time without dupicates. please help!! heres the code <script language="JavaScript"> function random_imglink(){ var myimages=new Array() //random images below myimages[1]="image1.jpg" myimages[2]="image2.jpg" myimages[3]="image3.jpg" //corresponding links below var imagelinks=new Array() imagelinks[1]="image1 link" imagelinks[2]="image2 link" imagelinks[3]="image3 link" //corresponding text below var imagetext=new Array() imagetext[1]="this is number 1" imagetext[2]="this is number 2" imagetext[3]="this is number 3" var ry=Math.floor(Math.random()*myimages.length) if (ry==0) ry=1 document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0><br>'+'"'+imagetext[ry]+'"'+'</a>') } random_imglink() //--> </script> Link to comment https://forums.phpfreaks.com/topic/175951-multiple-random-images-with-links-and-text/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.