I need to put two image arrays in one code with one that selects randomly and one that cycles. The codes both work when they are seperate but when they are put together only the first one works, this is the code:
<HTML>
<HEAD>
<TITLE>HTML and JavaScript</TITLE>
<SCRIPT>
var imgArray = new Array(4);
imgArray[0] = new Image;
imgArray[0].src = “winter2.jpg”;
imgArray[1] = new Image;
imgArray[1].src = “spring2.jpg”;
imgArray[2] = new Image;
imgArray[2].src = “summer2.jpg”;
imgArray[3] = new Image;
imgArray[3].src = “fall2.jpg”;
var index = 0;
function select()
{
index = Math.floor(Math.random() * 4);
document.banner.src = imgArray[index].src;
setTimeout(“select()”,1000);
return;
}
</SCRIPT>
<SCRIPT>
var imgSlide = new Array(4);
imgArray[0] = new Image;
imgArray[0].src = “winter.jpg”;
imgArray[1] = new Image;
imgArray[1].src = “spring.jpg”;
imgArray[2] = new Image;
imgArray[2].src = “summer.jpg”;
imgArray[3] = new Image;
imgArray[3].src = “fall.jpg”;
var index = 0;
function cycle()
{
document.seasons.src = imgSlide[index].src;
index++;
if (index == 4)
{
index = 0;
}
setTimeout(“cycle()”,2000);
return;
}
</SCRIPT>
</HEAD>
<BODY onLoad = “select()” onLoad = “cycle()”>
<CENTER>
<IMG NAME=”banner” SRC=”winter2.jpg”>
</CENTER>
<CENTER>
<IMG NAME=”seasons” SRC=”winter.jpg”>
</CENTER>
</BODY>
</HTML>