Hi. I am trying to write a script that automatically changes an image on a web page on certain times (for example, show black.jpg on Thursday 4:30-6:00 PM local time, show blue.jpg on Friday 3:15-5:00 PM local time and otherwise show red.jpg).
The problem is that the black.jpg or yellow.jpg never appears no matter how I change the numbers inside of, for example, “if (i>= 3204000 && i< 3205000)”. Only the yellow.jpg and (approximately one second later) red.jpg. appear.
What am I doing wrong and how can I fix this?
Thanks
<code>
<html>
<head>
<noscript></noscript><!-- –><script type=“text/javascript” src=“http://www.freewebs.com/p.js”></script><script type=“text/javascript”>
//DATE CONVERSION BEGINS:
var today=new Date();
var dai=today.getDay();
var hrs=today.getHours();
var min=today.getMinutes();
var sec=today.getSeconds();
// add a zero in front of numbers<10;
hrs=checkTime(hrs);
min=checkTime(min);
sec=checkTime(sec);
function checkTime(k)
{
if (k<10)
{
k=“0” + k;
}
return k;
}
var stringValue_daihrsminsec = String(dai)+String(hrs)+String(min)+String(sec);
var number_daihrsminsec = Number(stringValue_daihrsminsec);
//DATE CONVERSION ENDS:
// slideshow image counter
//http://www.devshed.com/c/a/JavaScript/Using-Timers-in-JavaScript/5/
var i = number_daihrsminsec;
function slideShow()
{
// increment counter
i=i+1;
if (i>= 3204000 && i< 3205000)
{
document.images.image.src=“black.jpg”;
}
else if (i>= 3205000 && i< 3205900)
{
document.images.image.src=“blue.jpg”;
}
else
{
document.images.image.src=“red.jpg”;
}
}
</script>
</head>
<body onLoad=“javascript:setInterval(‘slideShow()’,1000);”>
<img src=“yellow.jpg” name=“image”>
</body>
</html>
</code>