random hyperlinked images problem

admin

Administrator
Staff member
what i am trying to do is this: i have nine thumbnail images (in a td) on my htmlpage and i wrote a function to change one of the nine images randomly (from a list of 22 images total). so i have 3X3 images and i chose a position from 1 to 9 and then exchange the image (randomly from a list of 22 images) and then i chose the next position etc.

what i want to do now is have all the images with uneaven numbers hyperlinked. i tried to extend my script to dynamicly place a linktag when randomly chosing an image with uneaven number, but then it just gives me javascript errors....

heres my script without the links (just 3X3 images on a page, being randomly exchanged...):

<HEAD>
<script language="JavaScript">
<!--
var random1 = Math.round(Math.random()*21+1);
var random2 = Math.round(Math.random()*8);

function imageswap(){

var newsrc1 = 'randomstahl/pic' + random1 + '.jpg';
document.images[random2].src=newsrc1;
window.setTimeout("imageswap()", 1500);
}

//-->
</script>

</HEAD>

<BODY onLoad="imageswap();">

<CENTER>
<table width="700" border="0" cellspacing="1" cellpadding="0" bgcolor="#CCCCCC">
<tr>
<td colspan=6 bgcolor="#CCCCCC">
<center><h2><br> title </h2>
</TD>
</TR>
<TR>
<TD width="30"><spacer type="block" width="30">
&nbsp;
</TD>
<TD>
<br>
<img src=http://www.webdeveloper.com/forum/archive/index.php/"images/pic2.jpg" border="0">
</TD>
<TD>
<img src="images/pic4.jpg" border="0">
</TD>
<TD>
<img src="images/pic6.jpg" border="0">
</TD>
<TD>
<img src="images/pic8.jpg" border="0">


-->etc.-->etc.

so, all i want to do is: when my first picture is for example changed to pic1 by the script i want it to appear as a hyperlinked image... i would be really happy if someone could help me.... THANKS,
laleona
 
Back
Top