Hi There
This is my first time on the site. I am studing information technology and one of my subjects is HTML & Javascript. I am battling and have an assignment due, please help!
I need to use cycle & stop buttons to control the animation and javascript code to animate the images of a traffic light. I have drawn 3 pictures in Paint, each with a different colour illumated and saved as banner1.jpg, banner2.jpg & banner3.jpg respectively.
The screen layout is fine but I cannot get the cycle and stop function to work, there is obviously something very wrong in my code and being a "newbie" have no idea where to find the problem.
Any help will be appreciated.
My code so far:
<html>
<head>
<title>Questi on 3 Traffic Lights</title>
<SCRIPT LANGUAGE="JAVAS CRIPT>
<!-- Hide from old browsers
var banners = new Array("banner1. jpg","banner2.j pg","banner3.jp g")
var bnrCntr = 0
var timer
function bancycle() {
bnrCntr = bnrCntr + 1
if (bnrCntr == 3) {
bnrCntr = 0
}
document.Banner .src = banners[bnrCntr]
timer = setTimeout("ban cycle()",1000)
}
function stopcycle() {
clearTimeout(ti mer)
}
//-->
</script>
</head>
<body>
<img src="banner1.jp g" name="banner" width=110 height=200>
<form><input type="button" value="Cycle" name="Cycle" onclick="banCyc le()">
<input type="button" value="Stop" name="Stop" onclick="stopCy cle()">
</form>
</body>
This is my first time on the site. I am studing information technology and one of my subjects is HTML & Javascript. I am battling and have an assignment due, please help!
I need to use cycle & stop buttons to control the animation and javascript code to animate the images of a traffic light. I have drawn 3 pictures in Paint, each with a different colour illumated and saved as banner1.jpg, banner2.jpg & banner3.jpg respectively.
The screen layout is fine but I cannot get the cycle and stop function to work, there is obviously something very wrong in my code and being a "newbie" have no idea where to find the problem.
Any help will be appreciated.
My code so far:
<html>
<head>
<title>Questi on 3 Traffic Lights</title>
<SCRIPT LANGUAGE="JAVAS CRIPT>
<!-- Hide from old browsers
var banners = new Array("banner1. jpg","banner2.j pg","banner3.jp g")
var bnrCntr = 0
var timer
function bancycle() {
bnrCntr = bnrCntr + 1
if (bnrCntr == 3) {
bnrCntr = 0
}
document.Banner .src = banners[bnrCntr]
timer = setTimeout("ban cycle()",1000)
}
function stopcycle() {
clearTimeout(ti mer)
}
//-->
</script>
</head>
<body>
<img src="banner1.jp g" name="banner" width=110 height=200>
<form><input type="button" value="Cycle" name="Cycle" onclick="banCyc le()">
<input type="button" value="Stop" name="Stop" onclick="stopCy cle()">
</form>
</body>
Comment