Click to See Complete Forum and Search --> : A little Help please...


dragoon
12-30-2003, 12:37 AM
I have a javascript that's supposed to put up a different message depending on what time it is... but it doesn't seem to be working on my site...

anyone that can help, I would very much be appreciative...

Pittimann
12-30-2003, 01:26 AM
Hi!

Could you please post the code you are using??

Cheers - Pit

dragoon
12-30-2003, 01:35 AM
Here's the code:


<SCRIPT language="javascript">
document.write(" <FONT size=-1 face="Verdana"><b>Greetings from ");
day = new Date();
hr = day.getHours();
if ((hr >= 1) && (hr <=5)) {
t = "<FONT color=CC9999>Lissa</FONT>: 'My, my... What are you doing up at this ungodly hour? Oh, "Early to bed"?'";}
if ((hr >= 6) && (hr <=11)) {
t = "<FONT color=CC9999>Lissa</FONT>: 'Good Morning. If you want to take a look at what's here, you know what to do...'";}
if ((hr >= 12) && (hr <=16)) {
t = "<FONT color=CC9999>Lissa</FONT>: 'You know... it's not good to eat lunch and surf the web at the same time... You'll get food in the keyboard.'";}
if ((hr >= 17) && (hr <=21)) {
t = "<FONT color=CC9999>Lissa</FONT>: 'Ahhh... Nothing soothes the nerves like a good soak in a data stream...'";}
if ((hr == 22) || (hr ==23)) {
t = "<FONT color=CC9999>Lissa</FONT>: 'Wow... I never thought that people could eat dinner, watch TV, and surf the web at the same time... I thought 'I' was coordinated...'";}
if (hr==0) {
t = "<FONT color=CC9999>Lissa</FONT>: 'Okay... Hold it you! What are you still doing up? It's way past your bedtime!! Go on! Shoo!'";}
document.write(t);
document.write("</b></FONT>");
</SCRIPT>
</TD>
</TR>
</TABLE>

Pittimann
12-30-2003, 01:47 AM
Hi!

You put double quotes inside a double quoted document.write:
document.write(" <FONT size=-1 face="Verdana"><b>Greetings from ");
day = new Date();
hr = day.getHours();
if ((hr >= 1) && (hr <=5)) {
t = "<FONT color=CC9999>Lissa</FONT>: 'My, my... What are you doing up at this ungodly hour? Oh, "Early to bed"?'";}
If you escape the red marked quotes with a backslash (means: replace " with \") it will work.

Cheers - Pit

dragoon
12-30-2003, 01:52 AM
Ah... Thank you very much for your help!