Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 18th, 2004, 03:55 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default Don't Ya Just Hate This?

This is the first day of my Javascript: An Introduction class and I am already having problems with a bit of Javascript code on a web page.

This is the code.


Code:
<SCRIPT LANGUAGE="JAVASCRIPT">
<!-- Hide the script from older browsers --
  today = new Date()
if ((today.getHours() >=4) && (today.getHours() <=12)){
  document.write("Good Morning.  Have a rush job for the afternoon? We can handle it!")
}
if ((today.getHours() >12) && (today.getHours() <=18)){
  document.write("Good afternoon.  We can get that print job ready by tomorrow morning.")
}
if ((today.getHours() >18) && (today.getHours() <=23)){
  document.write("Good evening.  We will be here all night if you need us!")
if ((today.getHours() >=0) && (today.getHours() <4)){
  document.write("Yes, we are working at this hour!")
}
// -- End hiding here -->
</SCRIPT>

The message I get is telling me that there is an error on line 27 which I have highlighted in red for easier noticing

Ben Horne
LDS Test And Measurement, Inc



-------------------------
http://www.geocities.com/valerian5200/index.html

"There are two kinds of people in the world: Those who claim to be Flash junkies and those who actually are Flash junkies"
__________________
Ben Horne
-------------------------
I don\'t want to sound like I haven\'t made any mistakes. I\'m confident I have.

Most likely using FireFox and concocting my next Macromedia Flash project
Snibworks Forums Moderator

Welcome to the New Age
 
Old October 18th, 2004, 08:23 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Prepare to smack yourself...

You're missing a closing brace after the document.write() statement after the third if-else statement!

  today = new Date()
if ((today.getHours() >=4) && (today.getHours() <=12)){
  document.write("Good Morning. Have a rush job for the afternoon? We can handle it!")
}
if ((today.getHours() >12) && (today.getHours() <=18)){
  document.write("Good afternoon. We can get that print job ready by tomorrow morning.")
}
if ((today.getHours() >18) && (today.getHours() <=23)){
  document.write("Good evening. We will be here all night if you need us!")
} // <--- here it is
if ((today.getHours() >=0) && (today.getHours() <4)){
  document.write("Yes, we are working at this hour!")
}

-Snib <><
Try new FreshView 0.2!
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
 
Old October 18th, 2004, 09:41 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default

That's funny. I was entering it exactly like my textbook for the Introduction To Javascript course had it. However, it's been my experience that textbooks can be inaccurate. I guess this is another time that I've dealt with this.

Anyways, thanks for pointing this out, Snib.

BTW, I gotta change my signature a bit

Ben Horne
LDS Test And Measurement, Inc



-------------------------
http://www.geocities.com/valerian5200/index.html

"There are two kinds of people in the world: Those who claim to be Flash junkies and those who actually are Flash junkies"
 
Old October 18th, 2004, 09:46 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default

A word of wisdom: Never fully trust any computer textbook. Most often, they can be wrong about any particular thing.

Ben Horne




-------------------------
I don't want to sound like I haven't made any mistakes. I'm confident I have.

Welcome to the New Age





Similar Threads
Thread Thread Starter Forum Replies Last Post
GUI I hate the default Apocolypse2005 Visual Basic 2005 Basics 2 April 9th, 2008 07:46 PM
Please help! i hate...double and single quotes... keita Classic ASP Basics 3 March 28th, 2007 11:12 AM
Anybody else learning to HATE pear::DB? biot023 BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 2 March 15th, 2005 04:58 AM
easy one for ya! treasacrowe Classic ASP Databases 1 August 17th, 2004 08:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.