Click to See Complete Forum and Search --> : day of the week display


chris9902
02-10-2004, 07:06 AM
i want to use a CSS style changer on my site but i want to change the background to display a different picture for each day of the week.

something like

<div id="header_monday"></div>
<div id="header_tuesday"></div>
<div id="header_wednesday"></div>
<div id="header_thursaday"></div>
<div id="header_friday"></div>
<div id="header_saturday"></div>
<div id="header_sunday"></div>

any help would be very welcome

gil davis
02-10-2004, 07:40 AM
<style type="text/css">
#header_monday {background-image: url(monday.jpg);}
...
</style>

chris9902
02-10-2004, 08:57 AM
NO. i need a javascript that will change the div tags depending on the day

gil davis
02-10-2004, 10:12 AM
<head>
<style type="text/css">
.header_monday {background-image: url(monday.jpg);}
.header_tuesday {background-image: url(tuesday.jpg);}
.header_wednesday {background-image: url(wednesday.jpg);}
.header_thursday {background-image: url(thursday.jpg);}
.header_friday {background-image: url(friday.jpg);}
.header_saturday {background-image: url(saturday.jpg);}
.header_sunday {background-image: url(sunday.jpg);}
</style>
<script language="JavaScript">
var today = new Date();
var _wkdy = new Array("sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday");
var bgFile = "header_" + _wkdy[today.getDay()];
</script>
</head>
<body>
<script>
document.write("<div class='" + bgFile + "'>");
</script>
<!-- place whatever goes in the DIV here -->
</div>
</body>

chris9902
02-10-2004, 12:06 PM
i was not shouting

THIS IS SHOUTING

anyway THANK YOU:)

gil davis
02-10-2004, 01:51 PM
I wasn't sure what you were looking for. My example doesn't actually "change" the CSS style, it chooses it based on the day of the week. If you wanted to actually change the style, you'd have to do something after the object was loaded, and that might look a little weird. I thought that writing the specific class would be a better solution, both visually and from a cross-browser perspective.

chris9902
02-10-2004, 02:19 PM
what you posted was perfect.