I'm new to this forum. I need to place two images on my website. I want from 12am to 4pm, to display "Off.png",
4pm to 10pm, to display "On.png",
10pm to 12am, to display "Off.png",
How can I do this? I new to website work. But I'm a little slow on the javascript. I'm open to any method! If you can S-P-E-L-L out what I place, and where, that would be great.
Ray
12-06-2011, 04:08 AM
Quarath
Ie like this (put this code anywhere where you want your image):
Code:
<img src="" alt="" name="OnOff" id="OnOff" />
<script type="text/javascript">
var d = new Date();
var elem = document.getElementById('OnOff')
if ((d.getHours() > 16) && (d.getHours() < 23)) {
elem.src = 'On.png';
elem.alt = 'On';
}
else {
elem.src = 'Off.png';
elem.alt = 'Off';
}
</script>
12-07-2011, 05:02 PM
ny_yankee_25
Thanks, Works perfectly! I really owe you. See here: poestenkill-lights.com