S
Sande
I haven't used JavaScript in awhile and am trying to practice. I'm
having trouble getting a very simple conditional statement to work. The
Netscape JavaScript Console is telling me that "If is not defined". But
it looks to me as if it is defined and a similar statement adapted from
a script I found on the web does work. Could someone tell me what I'm
missing?
This script doesn't work. Note that I attempted to use this on the 28th,
so it should have evaluated as true.
var cDate=new Date();
If (cDate.getDate() == 28)
{
document.write ("Winter is not a season, it's an
occupation. Sinclair Lewis");
}
Else
{
document.write ("The condition did not evaluate
to 'true'.");
}
But when I tried, the following (running it before noon), it did work:
if (cDate.getHours() < 12)
{
document.write("Good Morning");
}
Thanks,
Sande
having trouble getting a very simple conditional statement to work. The
Netscape JavaScript Console is telling me that "If is not defined". But
it looks to me as if it is defined and a similar statement adapted from
a script I found on the web does work. Could someone tell me what I'm
missing?
This script doesn't work. Note that I attempted to use this on the 28th,
so it should have evaluated as true.
var cDate=new Date();
If (cDate.getDate() == 28)
{
document.write ("Winter is not a season, it's an
occupation. Sinclair Lewis");
}
Else
{
document.write ("The condition did not evaluate
to 'true'.");
}
But when I tried, the following (running it before noon), it did work:
if (cDate.getHours() < 12)
{
document.write("Good Morning");
}
Thanks,
Sande