944,044 Members | Top Members by Rank

Ad:
Mar 20th, 2005
0

Random image with text and link

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Hjcooke is offline Offline
15 posts
since Oct 2004
Mar 20th, 2005
0

Re: Random image with text and link

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>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Hjcooke is offline Offline
15 posts
since Oct 2004
Mar 21st, 2006
0

Re: Random image with text and link

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Designco is offline Offline
3 posts
since Mar 2006
Jul 13th, 2007
0

Re: Random image with text and link

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>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
CassieBeth is offline Offline
2 posts
since Jul 2007
Jul 13th, 2007
0

Re: Random image with text and link

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>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
CassieBeth is offline Offline
2 posts
since Jul 2007
Apr 19th, 2008
0

Re: Random image with text and link

That's pretty slick.

Does anyone know how to make the links open in a new window?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tokyotom is offline Offline
1 posts
since Apr 2008
Apr 19th, 2008
0

Re: Random image with text and link

Just basics touched on w3schools.com

Quote ...
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)
  1. <a href="http://www.w3schools.com/"
  2. target="_blank">Visit W3Schools!</a>
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 874
Code tags enforcer
peter_budo is offline Offline
6,658 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: How to fill the content with Ajax AFTER page fully loaded
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: How to change ONLY the color of text on MouseOver/Out?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC