daveo1
10-24-2003, 11:02 AM
I am looking for a script that checks the current date and then displays text depending on the date. Basically I want to be able to display a different line of text each day on a web page automatically. Does this make sense to any one and can any one help?
thanks
Khalid Ali
10-24-2003, 11:09 AM
var today = new Date();
the above will give you todays date from your system.
then create an array with seven values representing each day of the week(by default Sunday = 0 index in the array)
and then retrieve the string depending upon the day
dataArray[today.getDay()]
Something like this will display a different bit of text for each day of the month:
<script type="text/javascript">
text = new Array("day one", "day two", "day three", "day four", "day five", "day six", "day seven", "day eight", "day nine", "day ten",
"day eleven", "day twelve", "day thirteen", "day fourteen", "day fifteen", "day sixteen", "day seventeen", "day eighteen", "day nineteen", "day twenty",
"day twenty-one", "day twenty-two", "day twenty-three", "day twenty-four", "day twenty-five", "day twenty-six", "day twenty-seven", "day twenty-eight", "day twenty-nine", "day thirty", "thirty-one");
alert (text[new Date().getDate()-1]);
</script>