PDA

View Full Version : Javascript changing image regarding hour - HELP PLEASE!!


ineedhelpplease
01-17-2008, 08:42 PM
Hi there, I need some desperate help with this please.

I have created a map, and need to have a DHTML layer which I need to create.

But this layer must be created with regarding what time it is in the day.

For example:

3am-12pm (Morning) - To display a layer on the map where it is the best place to go in the morning.

12pm-5pm (Afternoon) - To display a layer on the map where it is the best place to go in the afternoon.

5pm-10pm (Evening) - To display a layer on the map where it is the best place to go in the evening.

10pm-3am (Night) - To display a layer on the map where it is the best place to go at night.

If someone can help write the code, I am willing to give a gift for my gratitude.

Thanks very much

Kor
01-18-2008, 12:11 PM
Could be something like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<style type="text/css">
#container div {
display:none;
}
</style>
<script type="text/javascript">
onload=function(){
var today= new Date();
var h=today.getHours();
var i=h<3?3:h<12?0:h<17?1:h<22?2:3;
document.getElementById('container').getElementsByTagName('div')[i].style.display='block';
}
</script>
</head>
<body>
<div id="container">
<div>Morning</div>
<div>Afternoon</div>
<div>Evening</div>
<div>Night</div>
</div>
</body>
</html>