Click to See Complete Forum and Search --> : Christmas greeting according to day


Xeenslayer
12-10-2002, 04:19 AM
Hi all. I've just tried doing a simple script. Here's the script:
______________________________

<script language="JavaScript">

var curdate=new Date()
day=curdate.getDate()

days_left=25-day

if(day<=25)
{document.write("<span>Jack wishes you an early Christmas!<br><br> "+days_left+" days till Christmas...</span><br><br>"); }

if(day==25)
{document.write("<span>Jack wishes you and your family a Merry Christmas!!</span><br><br>"); }

</script>
______________________________

I hope to have a code where on days before the 25th, it would display text saying:

"Jack wishes you an early Christmas!


X days till Christmas...

and on the 25th itself, the page will display:

Jack wishes you and your family a Merry Christmas!!

However, this script shows me all of messages on the 25th. How can I change it in a way that it shows only one?

Xeenslayer
12-11-2002, 12:29 AM
Thanks Dave. :) I just came up with the script and as I've tested, it works perfect.

Here's the script anyway:
______________________________

<script language="JavaScript"> <!--


// CHRISTMAS GREETING
var curdate=new Date()
day=curdate.getDate()

days_left=25-day

msgs=new Array()
msgs[0]="<span class='25thmsg' style='font-size:17px'>It's still early, and there are another "+days_left+" days till Christmas.</span><br><br><br><br>"
msgs[1]="<span class='25thmsg' style='font-size:20px'>Jack wishes you and your family a Merry Christmas!!</span><br><br><br><br>"

if(days_left==0)
{
document.write(msgs[1])
}

else
{
document.write(msgs[0])
}

//--> </script>
______________________________

The only problem is that after the 25th, the text will appear weird (-3 days left till Christmas, for example). :D