Click to See Complete Forum and Search --> : help adding link to random image script


nekochan
07-14-2003, 09:27 AM
I would like to add a link to this random image code
but I have had no louck so far..i am running several instances of it on my friends page at http://brentclark.org/home.html

there is one peice of script in the head:

function rndImage(numImages,h,w){
var randomImg = Math.floor(Math.random()*numImages) + 1;
document.write('<img src="randomImg/' + randomImg + '.jpg" height="' + h + '" width="' + w
+ '" >');

and then each instance is controlled by

var numImages = 5;
var randomImg = Math.floor(Math.random()*numImages) + 1;
document.write('<img src="portgalthn/' + randomImg + '.jpg">');
</script>

whihc are basically "Category" thumbnails. I would like to make each thumbnail link to a URL

i am designer so my knowledge in the area is to look and learn by example....this one has me stumped

any help appreciated

Khalid Ali
07-14-2003, 10:29 AM
What you can do is either create pages in a uniform naminf convention that will sync with the images and then use this

document.write('<a href="page_'+randomImg +'.html"><img src="randomImg/' + randomImg + '.jpg" height="' + h + '" width="' + w
+ '" ></a>');

This should work

nekochan
07-14-2003, 11:55 AM
Khalid,

just adding the
<a href="journalism.htm">
to the document.write portion
did exactly what I wanted.

thanks very very much for your quick assistance!

Neko