Hello,
I have used the below code, found on a forum from 2006, to generate a random image on my website with a link and accompanying text.
The image works fine, the link that goes with each image is fine…
Problem is: the text beneath the image does not match the image and link. This seems to be generated as a separate random element.
Can anyone tell me how I can make my site display image 1 + link 1 + quotation 1? The code is tested here: [url]http://www.velvetcommunications.co.uk/randomtest.html
The code is below. Hope someone can help ?
[CODE]<script language=”JavaScript”>
<!– Hide from old browsers
var imagenumber = 9 ;
var randomnumber = Math.random() ;
var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1 ;
images = new Array
images[1] = “jpg/clientlist/collagenics.jpg”
images[2] = “jpg/clientlist/cosmeticdental.jpg”
images[3] = “jpg/clientlist/cpt.jpg”
images[4] = “jpg/clientlist/glamal.jpg”
images[5] = “jpg/clientlist/mac_logo.jpg”
images[6] = “jpg/clientlist/mb.jpg”
images[7] = “jpg/clientlist/myi.jpg”
images[8] = “jpg/clientlist/ruck_logo.jpg”
images[9] = “jpg/clientlist/stagecoach.jpg”
var image = images[rand1]
links = new Array
links[1] = “collagen.html”
links[2] = “cosmetic.html”
links[3] = “cpt.html”
links[4] = “glamal.html”
links[5] = “mac.html”
links[6] = “megabus.html”
links[7] = “myi.html”
links[8] = “ruck.html”
links[9] = “stagecoach.html”
var link = links[rand1]
var Quotation=new Array()
Quotation[1] = “collagen”;
Quotation[2] = “cosmetic.”;
Quotation[3] = “cpt.”;
Quotation[4] = “glamal.”;
Quotation[5] = “mac.”;
Quotation[6] = “megabus.”;
Quotation[7] = “myi.”;
Quotation[8] = “ruck.”;
Quotation[9] = “stagecoach.”;
document.write(‘<A HREF=”‘ + link + ‘”><IMG SRC=”‘ + image + ‘” border=”0″></a>’)</script></td>
<td valign=”top” width=”98%”>
<script language=”JavaScript”>var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*(Q-1));
function showQuotation(){document.write(Quotation[whichQuotation]);}
showQuotation();</script>