Re: javascript, random quotes/images

by Romek <zylla(at)>

 Date:  Fri, 15 Sep 2000 10:42:47 +0000
 To:  hwg-techniques(at)
 References:  jps
  todo: View Thread, Original
At  14:51 9/14/2000 -0700,  Roger Harness  wrote:
>dear techniques gods/goddesses,
>I'm trying to do a random image/quote page using JavaScript.
>I CAN get the page to display a random image, and a random quote, but I'm
>having troubles getting the page to show a random image along WITH the
>coinsiding random quote.=20

>So maybe my question is more along the lines of: how can i place my image
>in a cell, and my quote in a cell, and have them coinside? I think I saw
>somewhere where you can turn both the image, and the quote into a varable,
>THEN place 'em into a page, but it seems like there's another, easier (?)
>way. Maybe not?

  Basically you need call your random function once;
  remember the chosen number in the variable;
  use that number in the picture pick;
  use that number in the quote;
  That's it.

<table border=3D0><tr><td>
<script language=3D"JavaScript"><!--

  var pick=3Drand(pictures.length);

//  and be sure  pictures.length is equal to quotes.length
//  otherwise the script will screw things up

  document.write(pictures[ pick ]);    //display random image

// --></script>
<script language=3D"JavaScript"><!--

  document.write(quotes[ pick ]);      //display randome quote

// --></script></td></tr></table>

>Roger Harness

      ~~~~ PeCetologia to nauka doswiadczalna =A9 ~~~~

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA