In military time, there is no such value as '24:00', it become '00:00'
But you can name the image whatever you want.
Consider this shortened code...
Code:
<!DOC HTML>
<html>
<head>
<title> Untitled </title>
<script type="text/javascript">
// From: http://www.webdeveloper.com/forum/showthread.php?t=253363
var baseURL = ''; // set this to the directory where the images are located
var hourImages = [
'2400.jpg',
'0100.jpg','0200.jpg','0300.jpg','0400.jpg',
'0500.jpg','0600.jpg','0700.jpg','0800.jpg',
'0900.jpg','1000.jpg','1100.jpg','1200.jpg',
'1300.jpg','1400.jpg','1500.jpg','1600.jpg',
'1700.jpg','1800.jpg','1900.jpg','2000.jpg',
'2100.jpg','2200.jpg','2300.jpg' // Note: NO COMMA after last entry
// ,'2400.jpg' // No such military time entry, hence the moving to 1st element
];
function pixTimeChange() {
var t=new Date();
var h = t.getHours();
document.getElementById('myimage').src = baseURL+hourImages[h];
document.getElementById('myimage').alt = hourImages[h];
}
window.onload = function() {
pixTimeChange();
}
</script>
</head>
<body>
<img id="myimage" src="" alt="">
</body>
</html>
Last edited by JMRKER; 11-12-2011 at 08:15 AM.
Reason: DANG..."Logic Ali" type faster than me!
Bookmarks