| | |
Random image with text and link
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2004
Posts: 15
Reputation:
Solved Threads: 0
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.
I wan tthe specific text to apear with the corresponding image and link.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<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>
•
•
Join Date: Jul 2007
Posts: 2
Reputation:
Solved Threads: 0
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 

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<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>
•
•
Join Date: Jul 2007
Posts: 2
Reputation:
Solved Threads: 0
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 

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<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>
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:
HTML Syntax (Toggle Plain Text)
<a href="http://www.w3schools.com/" target="_blank">Visit W3Schools!</a>
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- Show Nav image on mouse over text link (JavaScript / DHTML / AJAX)
- Random text display with image, link (PHP)
- Text link with me 4000+ uniques a day and growing! (Relevant Link Exchanges)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: How to fill the content with Ajax AFTER page fully loaded
- Next Thread: How to change ONLY the color of text on MouseOver/Out?
| Thread Tools | Search this Thread |
ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate automatically beta box browser bug calendar captchaformproblem checkbox child class close column createrange() css cursor date debugger dependent disablefirebug dom download dropdown editor element embed engine error events explorer ext file form forms getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe images internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jump libcurl math media microsoft mimic object onmouseoutdivproblem onreadystatechange parent paypal pdf php player position post problem programming progressbar regex runtime scroll search security select shopping size software sql text textarea unicode w3c web website window windowofwords windowsxp wysiwyg \n






