Hello everyone! I need help with my code, I want to alternate more than just 2 images using a function and setInterval. Here is my code, can anyone tell me what's wrong with it?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Banner Advertising</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
body { font-family: "Trebuchet MS" }
</style>
<script type="text/javascript">
/* <![CDATA[ */
var intImage = 2;
function concerts(){
switch (intImage){
case 1:
document.images[0].src = "concert1.gif";
intImage = 2;
break;
case 2:
document.images[0].src = "concert2.gif";
intImage = 1;
break;
case 3:
document.image[0].src = "concert3.gif";
intImage = 4;
break;
case 4:
document.image[0].src = "concert4.gif";
intImage = 5;
break;
case 5:
document.image[0].src = "concert5.gif";
intImage = 1;
break;
}
}
/* ]]> */
</script>
</head>
<body onload="var begin=setInterval('concerts()',5000);">
<p><img src="concert1.gif" alt="Changing concert advert images" /></p>
</body>
</html>
I also tried using if... else but I'm not cracking it. :?: