Forum Moderators: open
I'm fairly new to javascript (it shows).
I've nearly created a web page that displays images in one part of the page. Using onclick for a previous/ next arrangement. I want to load in the prev or next image.
And its not working.
I did it to randonly display the images in the array, but when I susbstitute this for onclick, it doesn't work. The two functions I use are rightimage and leftimage().
Help!
Thanks
Andy.
Here is the relevant code.
function leftimage()
{
var choice= choice--;
document.write('<IMG SRC="'+imageArray[choice]+'" height="400" width="370" border="0">');
}
function rightimage()
{
//document.stock_photo.src="next.gif";
document.write('<IMG SRC="'+imageArray[choice]+'" height="400" width="370" border="0">');
choice++;
}
// Write out an IMG tag, using a randomly-chosen image name.
var choice = pickRandom(n);
//var choice = 9;
// -->
</script>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body >
<table width="100%" height="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<table width="760" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="right" valign="bottom"><ul id="navMenu"><li id="NavSelected"><a HREF="Jane Home.htm"> home </a></li><!--
--><li><a HREF="profile.htm"> profile </a></li><!--
--><li><a HREF="editorial.htm"> editorials </a></li><!--
--><li><a HREF="books.htm"> books </a></li><!--
--><li><a HREF="contact.htm"> contact </a></li></ul></td>
</tr>
</table>
<table width="760" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="19">
<img SRC="images/corner1.gif" width="19" height="19" /></td>
<td bgcolor="#FFFFFF">
<img SRC="images/spacer.gif" width="371" height="19" /></td>
<td rowspan="3">
<td rowspan="3"><SCRIPT LANGUAGE="JavaScript">document.write('<IMG SRC="'+imageArray[choice]+'" height="400" width="370" border="0">');</SCRIPT></td>
<form>
<input type="button" value="previous"
onClick="leftimage()">
<input type="button" value="forward"
onClick="rightimage()">
</form></script></td>
</div>
</tr>
<tr>
<td bgcolor="#FFFFFF">
<img SRC="images/spacer.gif" width="19" height="362" /></td>
<td align="left" valign="top" bgcolor="#FFFFFF" >
<img SRC="JClogo.jpg" width="300" height="250"><br>
<br><br><br>