
Originally Posted by
musc3
Hi David,if i wanted to change and image every 12 hours for 30 days,would i change the code to
<!-- Begin
today = new Date();
day = today.getDay();
arday = new Array("sunday12am.jpg","sunday12pm.jpg", "monday.jpg", "tuesday.jpg",
"wednesday.jpg", "thursday.jpg", "friday.jpg", "saturday.jpg");
document.write("<img src='" + arday[day] + "'>");
// End -->
</SCRIPT> would i continue doing that for every day of the month,or it would be totally be diffrent. thks in advance .
No, you would do something like:
Code:
<script language="javascript">
<!-- Begin
var today = new Date();
var day = today.getDay();
var hour = today.getHours();
var daysAM = new Array("sundayAM.jpg", "mondayAM.jpg", "tuesdayAM.jpg", "wednesdayAM.jpg", "thursdayAM.jpg", "fridayAM.jpg", "saturdayAM.jpg");
var daysPM = new Array("sundayPM.jpg", "mondayPM.jpg", "tuesdayPM.jpg", "wednesdayPM.jpg", "thursdayPM.jpg", "fridayPM.jpg", "saturdayPM.jpg");
if(hour < 12)
document.write('<img src="' + daysAM[day] + '" />');
else
document.write('<img src="' + daysPM[day] + '" />');
// End -->
</script>
bear in mind I didn't test this, but assuming I didn't make a typos it should work.
You also would need to create the two images, ie.. sundayAM.jpg and sundayPM.jpg, for each day of the week. The name of the images can be changed but make sure you change it in the corresponding name in the javascript