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
Reply

Join Date: Oct 2004
Posts: 15
Reputation: Hjcooke is an unknown quantity at this point 
Solved Threads: 0
Hjcooke Hjcooke is offline Offline
Newbie Poster

Random image with text and link

 
0
  #1
Mar 20th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 15
Reputation: Hjcooke is an unknown quantity at this point 
Solved Threads: 0
Hjcooke Hjcooke is offline Offline
Newbie Poster

Re: Random image with text and link

 
0
  #2
Mar 20th, 2005
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.

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1.  
  2. <script language="JavaScript">
  3. <!-- Hide from old browsers
  4.  
  5. var imagenumber = 9 ;
  6. var randomnumber = Math.random() ;
  7. var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1 ;
  8. images = new Array
  9. images[1] = "tc.gif"
  10. images[2] = "airtours.gif"
  11. images[3] = "clubmed.gif"
  12. images[4] = "firstchoice.gif"
  13. images[5] = "thefirstresort.gif"
  14. images[6] = "JMC.gif"
  15. images[7] = "thomson.gif"
  16. images[8] = "nextag.gif"
  17. images[9] = "portlanddirect.gif"
  18. var image = images[rand1]
  19.  
  20.  
  21. links = new Array
  22. links[1] = "http://www.thomascook.co.uk"
  23. links[2] = "http://www.airtours.co.uk"
  24. links[3] = "http://www.clubmed.co.uk"
  25. links[4] = "http://www.firstchoice.co.uk"
  26. links[5] = "http://www.thefirstresort.co.uk"
  27. links[6] = "http://www.jmc.co.uk"
  28. links[7] = "http://www.thomson.co.uk"
  29. links[8] = "http://www.nextag.co.uk"
  30. links[9] = "http://www.portlanddirect.co.uk"
  31. var link = links[rand1]
  32.  
  33. var Quotation=new Array()
  34.  
  35.  
  36. Quotation[1] = "tomascook";
  37. Quotation[2] = "airtours.";
  38. Quotation[3] = "clubmed.";
  39. Quotation[4] = "firstchoice.";
  40. Quotation[5] = "thefirstresort.";
  41. Quotation[6] = "jmc.";
  42. Quotation[7] = "thomson.";
  43. Quotation[8] = "nextag.";
  44. Quotation[9] = "portlanddirect.";
  45.  
  46.  
  47. var Q = Quotation.length;
  48. var whichQuotation=Math.round(Math.random()*(Q-1));
  49. function showQuotation(){document.write(Quotation[whichQuotation]);}
  50. showQuotation();
  51.  
  52.  
  53.  
  54. document.write('<A HREF="' + link + '"><IMG SRC="' + image + '" border="0"></a>')
  55.  
  56. </script>
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 3
Reputation: Designco is an unknown quantity at this point 
Solved Threads: 0
Designco Designco is offline Offline
Newbie Poster

Re: Random image with text and link

 
0
  #3
Mar 21st, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 2
Reputation: CassieBeth is an unknown quantity at this point 
Solved Threads: 0
CassieBeth CassieBeth is offline Offline
Newbie Poster

Re: Random image with text and link

 
0
  #4
Jul 13th, 2007
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)
  1.  
  2.  
  3. <table width="100%" border="0" cellspacing="1" cellpadding="1">
  4. <tr>
  5. <td width="2%">
  6. <script language="JavaScript">
  7. <!-- Hide from old browsers
  8.  
  9. var imagenumber = 9 ;
  10. var randomnumber = Math.random() ;
  11. var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1 ;
  12.  
  13.  
  14. images = new Array
  15. images[1] = "../image/day.gif"
  16. images[2] = "../image/day.gif"
  17. images[3] = "../image/day.gif"
  18. images[4] = "../image/day.gif"
  19. images[5] = "../image/day.gif"
  20. images[6] = "../image/day.gif"
  21. images[7] = "../image/day.gif"
  22. images[8] = "../image/day.gif"
  23. images[9] = "../image/day.gif"
  24. var image = images[rand1]
  25.  
  26.  
  27. links = new Array
  28. links[1] = "http://www.thomascook.co.uk"
  29. links[2] = "http://www.airtours.co.uk"
  30. links[3] = "http://www.clubmed.co.uk"
  31. links[4] = "http://www.firstchoice.co.uk"
  32. links[5] = "http://www.thefirstresort.co.uk"
  33. links[6] = "http://www.jmc.co.uk"
  34. links[7] = "http://www.thomson.co.uk"
  35. links[8] = "http://www.nextag.co.uk"
  36. links[9] = "http://www.portlanddirect.co.uk"
  37. var link = links[rand1]
  38.  
  39. var Quotation=new Array()
  40.  
  41.  
  42. Quotation[1] = "tomascook";
  43. Quotation[2] = "airtours.";
  44. Quotation[3] = "clubmed.";
  45. Quotation[4] = "firstchoice.";
  46. Quotation[5] = "thefirstresort.";
  47. Quotation[6] = "jmc.";
  48. Quotation[7] = "thomson.";
  49. Quotation[8] = "nextag.";
  50. Quotation[9] = "portlanddirect.";
  51.  
  52. document.write('<A HREF="' + link + '"><IMG SRC="' + image + '" border="0"></a>')</script></td>
  53.  
  54.  
  55.  
  56. <td valign="top" width="98%"><font face="Arial, Helvetica, sans-serif" size="1" color="#000000">
  57. <script language="JavaScript">var Q = Quotation.length;
  58. var whichQuotation=Math.round(Math.random()*(Q-1));
  59. function showQuotation(){document.write(Quotation[whichQuotation]);}
  60. showQuotation();</script></font>
  61. </td>
  62. </tr>
  63. </table>
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 2
Reputation: CassieBeth is an unknown quantity at this point 
Solved Threads: 0
CassieBeth CassieBeth is offline Offline
Newbie Poster

Re: Random image with text and link

 
0
  #5
Jul 13th, 2007
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)
  1.  
  2.  
  3. <table width="100%" border="0" cellspacing="1" cellpadding="1">
  4. <tr>
  5. <td width="2%">
  6. <script language="JavaScript">
  7. <!-- Hide from old browsers
  8.  
  9. var imagenumber = 9 ;
  10. var randomnumber = Math.random() ;
  11. var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1 ;
  12.  
  13.  
  14. images = new Array
  15. images[1] = "../image/day.gif"
  16. images[2] = "../image/day.gif"
  17. images[3] = "../image/day.gif"
  18. images[4] = "../image/day.gif"
  19. images[5] = "../image/day.gif"
  20. images[6] = "../image/day.gif"
  21. images[7] = "../image/day.gif"
  22. images[8] = "../image/day.gif"
  23. images[9] = "../image/day.gif"
  24. var image = images[rand1]
  25.  
  26.  
  27. links = new Array
  28. links[1] = "http://www.thomascook.co.uk"
  29. links[2] = "http://www.airtours.co.uk"
  30. links[3] = "http://www.clubmed.co.uk"
  31. links[4] = "http://www.firstchoice.co.uk"
  32. links[5] = "http://www.thefirstresort.co.uk"
  33. links[6] = "http://www.jmc.co.uk"
  34. links[7] = "http://www.thomson.co.uk"
  35. links[8] = "http://www.nextag.co.uk"
  36. links[9] = "http://www.portlanddirect.co.uk"
  37. var link = links[rand1]
  38.  
  39. var Quotation=new Array()
  40.  
  41.  
  42. Quotation[1] = "tomascook";
  43. Quotation[2] = "airtours.";
  44. Quotation[3] = "clubmed.";
  45. Quotation[4] = "firstchoice.";
  46. Quotation[5] = "thefirstresort.";
  47. Quotation[6] = "jmc.";
  48. Quotation[7] = "thomson.";
  49. Quotation[8] = "nextag.";
  50. Quotation[9] = "portlanddirect.";
  51.  
  52. document.write('<A HREF="' + link + '"><IMG SRC="' + image + '" border="0"></a>')</script></td>
  53.  
  54.  
  55.  
  56. <td valign="top" width="98%"><font face="Arial, Helvetica, sans-serif" size="1" color="#000000">
  57. <script language="JavaScript">var Q = Quotation.length;
  58. var whichQuotation=Math.round(Math.random()*(Q-1));
  59. function showQuotation(){document.write(Quotation[whichQuotation]);}
  60. showQuotation();</script></font>
  61. </td>
  62. </tr>
  63. </table>
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 1
Reputation: tokyotom is an unknown quantity at this point 
Solved Threads: 0
tokyotom tokyotom is offline Offline
Newbie Poster

Re: Random image with text and link

 
0
  #6
Apr 19th, 2008
That's pretty slick.

Does anyone know how to make the links open in a new window?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,190
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 483
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: Random image with text and link

 
0
  #7
Apr 19th, 2008
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:
  1. <a href="http://www.w3schools.com/"
  2. 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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC