I want to fix the button so that the user can click on it in order to start the traffic light slideshow. At the moment, it is interfering with the loop which means that when the user clicks on the button it will fasten the slideshow rather than start it.
<head>
<script type="text/javascript">
var image1 = new Image()
image1.src = "traffic light_1.png"
var image2 = new Image()
image2.src = "traffic light_2.png"
var image3 = new Image()
image3.src = "traffic light_3.png"
var image4 = new Image()
image4.src = "traffic light_2.png"
</script>
</head>
<body>
<p><img src="traffic light_1.png" width="800" height="500" name="slide" /></p>
<button onclick="slideit()">Click me</button>
<p id="demo"></p>
<script type="text/javascript">
var step=1;
function slideit()
{
document.images.slide.src = eval("image"+step+".src");
if(step<4)
step++;
else
step=1;
setTimeout("slideit()",4000);
}
slideit();
</script>
</body>