S
seven
This might be a newbie question or otherwise easy stuff for some of
you, but it's tweaking me ... can't seem to get it to work right.
I am working with a script that basically creates two arrays, and with
a single call in the html, randomly inserts a graphic (which is linked
to another page, as defined in the second array). The working example
is
http://seven.postmodern.com/insight/tarot/1cardreading.html
What I would like to do is call multiple instances of random images,
but the way I have it currently set up, I get the same random image if
I try to call it more than once - so I've tried defining additional
variables but perhaps I am doing it incorrectly. Can anyone help or
offer a tip/tutorial on this if possible? I can workaround by using a
frameset but that gets ugly if doing too many cards. help?
var imagenumber = 44 ;
var randomnumber = Math.random() ;
var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1 ;
images = new Array
images[1] = "image1.gif"
images[2] = "image2.gif"
....
images[44] = "image22r.gif"
var image = images[rand1]
links = new Array
links[1] = "image1.htm"
links[2] = "image2.htm"
....
links[44] = "image22r.htm"
var link = links[rand1]
/then it within the page, calls the graphic as such
<script language="JavaScript">
<!-- Hide this script from old browsers -->
document.write('<A HREF="' + link + '"target="_blank"><IMG SRC="' +
image + '" border="0"></a>')
<!-- End Hiding Here -->
</script>
you, but it's tweaking me ... can't seem to get it to work right.
I am working with a script that basically creates two arrays, and with
a single call in the html, randomly inserts a graphic (which is linked
to another page, as defined in the second array). The working example
is
http://seven.postmodern.com/insight/tarot/1cardreading.html
What I would like to do is call multiple instances of random images,
but the way I have it currently set up, I get the same random image if
I try to call it more than once - so I've tried defining additional
variables but perhaps I am doing it incorrectly. Can anyone help or
offer a tip/tutorial on this if possible? I can workaround by using a
frameset but that gets ugly if doing too many cards. help?
var imagenumber = 44 ;
var randomnumber = Math.random() ;
var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1 ;
images = new Array
images[1] = "image1.gif"
images[2] = "image2.gif"
....
images[44] = "image22r.gif"
var image = images[rand1]
links = new Array
links[1] = "image1.htm"
links[2] = "image2.htm"
....
links[44] = "image22r.htm"
var link = links[rand1]
/then it within the page, calls the graphic as such
<script language="JavaScript">
<!-- Hide this script from old browsers -->
document.write('<A HREF="' + link + '"target="_blank"><IMG SRC="' +
image + '" border="0"></a>')
<!-- End Hiding Here -->
</script>