Hi i have variouys different javascripts i have found on the net that allows me to generate random images, images as links and random text. Can any one help me create and all in one random genrator so i have text with an image as a link?

Many thanks

Hi, just put two scripts together and managed to get a picture being a link and text to appea, but the text does not coinside with the image and the link.

I wan tthe specific text to apear with the corresponding image and link.

<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] = "tc.gif"
images[2] = "airtours.gif"
images[3] = "clubmed.gif"
images[4] = "firstchoice.gif"
images[5] = "thefirstresort.gif"
images[6] = "JMC.gif"
images[7] = "thomson.gif"
images[8] = "nextag.gif"
images[9] = "portlanddirect.gif"
var image = images[rand1]


links = new Array
links[1] = "http://www.thomascook.co.uk"
links[2] = "http://www.airtours.co.uk"
links[3] = "http://www.clubmed.co.uk"
links[4] = "http://www.firstchoice.co.uk"
links[5] = "http://www.thefirstresort.co.uk"
links[6] = "http://www.jmc.co.uk"
links[7] = "http://www.thomson.co.uk"
links[8] = "http://www.nextag.co.uk"
links[9] = "http://www.portlanddirect.co.uk"
var link = links[rand1]

var Quotation=new Array() 


Quotation[1] = "tomascook";
Quotation[2] = "airtours.";
Quotation[3] = "clubmed.";
Quotation[4] = "firstchoice.";
Quotation[5] = "thefirstresort.";
Quotation[6] = "jmc.";
Quotation[7] = "thomson.";
Quotation[8] = "nextag.";
Quotation[9] = "portlanddirect.";


var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*(Q-1));
function showQuotation(){document.write(Quotation[whichQuotation]);}
showQuotation();



document.write('<A HREF="' + link + '"><IMG SRC="' + image + '" border="0"></a>')

</script>

Ho

I will use this script. Can a set this in the link ... target="_blank" ....

To open the link in a new window ???

Thanks / Danny

I know this thread is like forever old but I took the script and put the image and text into a table, switched the image to show on the left and the text is aligned to the top of the image. Pretty nifty :D

<table width="100%" border="0" cellspacing="1" cellpadding="1">
  <tr>
    <td width="2%">
<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] = "../image/day.gif"
images[2] = "../image/day.gif"
images[3] = "../image/day.gif"
images[4] = "../image/day.gif"
images[5] = "../image/day.gif"
images[6] = "../image/day.gif"
images[7] = "../image/day.gif"
images[8] = "../image/day.gif"
images[9] = "../image/day.gif"
var image = images[rand1]


links = new Array
links[1] = "http://www.thomascook.co.uk"
links[2] = "http://www.airtours.co.uk"
links[3] = "http://www.clubmed.co.uk"
links[4] = "http://www.firstchoice.co.uk"
links[5] = "http://www.thefirstresort.co.uk"
links[6] = "http://www.jmc.co.uk"
links[7] = "http://www.thomson.co.uk"
links[8] = "http://www.nextag.co.uk"
links[9] = "http://www.portlanddirect.co.uk"
var link = links[rand1]

var Quotation=new Array() 


Quotation[1] = "tomascook";
Quotation[2] = "airtours.";
Quotation[3] = "clubmed.";
Quotation[4] = "firstchoice.";
Quotation[5] = "thefirstresort.";
Quotation[6] = "jmc.";
Quotation[7] = "thomson.";
Quotation[8] = "nextag.";
Quotation[9] = "portlanddirect.";

document.write('<A HREF="' + link + '"><IMG SRC="' + image + '" border="0"></a>')</script></td>
   
   
   
    <td valign="top" width="98%"><font face="Arial, Helvetica, sans-serif" size="1" color="#000000"> 
      <script language="JavaScript">var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*(Q-1));
function showQuotation(){document.write(Quotation[whichQuotation]);}
showQuotation();</script></font> 
</td>
  </tr>
</table>

I know this thread is like forever old but I took the script and put the image and text into a table, switched the image to show on the left and the text is aligned to the top of the image. Pretty nifty :)

<table width="100%" border="0" cellspacing="1" cellpadding="1">
  <tr>
    <td width="2%">
<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] = "../image/day.gif"
images[2] = "../image/day.gif"
images[3] = "../image/day.gif"
images[4] = "../image/day.gif"
images[5] = "../image/day.gif"
images[6] = "../image/day.gif"
images[7] = "../image/day.gif"
images[8] = "../image/day.gif"
images[9] = "../image/day.gif"
var image = images[rand1]


links = new Array
links[1] = "http://www.thomascook.co.uk"
links[2] = "http://www.airtours.co.uk"
links[3] = "http://www.clubmed.co.uk"
links[4] = "http://www.firstchoice.co.uk"
links[5] = "http://www.thefirstresort.co.uk"
links[6] = "http://www.jmc.co.uk"
links[7] = "http://www.thomson.co.uk"
links[8] = "http://www.nextag.co.uk"
links[9] = "http://www.portlanddirect.co.uk"
var link = links[rand1]

var Quotation=new Array() 


Quotation[1] = "tomascook";
Quotation[2] = "airtours.";
Quotation[3] = "clubmed.";
Quotation[4] = "firstchoice.";
Quotation[5] = "thefirstresort.";
Quotation[6] = "jmc.";
Quotation[7] = "thomson.";
Quotation[8] = "nextag.";
Quotation[9] = "portlanddirect.";

document.write('<A HREF="' + link + '"><IMG SRC="' + image + '" border="0"></a>')</script></td>
   
   
   
    <td valign="top" width="98%"><font face="Arial, Helvetica, sans-serif" size="1" color="#000000"> 
      <script language="JavaScript">var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*(Q-1));
function showQuotation(){document.write(Quotation[whichQuotation]);}
showQuotation();</script></font> 
</td>
  </tr>
</table>

That's pretty slick.

Does anyone know how to make the links open in a new window?

Just basics touched on w3schools.com

The Target Attribute
With the target attribute, you can define where the linked document will be opened.
The line below will open the document in a new browser window:

<a href="http://www.w3schools.com/"
target="_blank">Visit W3Schools!</a>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.