Question

Locked

Javascript error in random image rotator?

By Men-an-tol ·
Can anybody with sharp eyes tell me where I've gone wrong please? It's ages since I wrote a script so it's probably obvious to someone...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
<!--
var gallery = new Array();
var gallery[0] = new Array("IMG_2112.JPG","IMG_2121.JPG","IMG_2141.JPG","IMG_2175.JPG","IMG_2210.JPG","IMG_2218.JPG","IMG_2228.JPG","IMG_2232.JPG");
var gallery[1] = new Array("IMG_2117.JPG","IMG_2190.JPG","IMG_2199.JPG","IMG_2215.JPG","IMG_2255.JPG","IMG_2258.JPG","IMG_2261.JPG");
var gallery[2] = new Array("rea.jpg","napit.jpg","mcs.jpg");

function pickImageFrom(whichGallery){
var idx = Math.floor(Math.random() * gallery[whichGallery].length);
document.write('<img src="thumbs/' + gallery[whichGallery][idx] + '">');
}
//-->
</script>

</head>
<body>

<div align="center">

<script language="javascript">pickImageFrom[0];</script>
<br />
<script language="javascript">pickImageFrom[1];</script>
<br />
<script language="javascript">pickImageFrom[2];</script>
</div>
</body>
</html>

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Share your knowledge
Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums