Turn your Mobile Apps into m-commerce apps – Learn More!

You're Browsing As A Guest! Register Now...
Become an Expert!

Join 415,729 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,865 people online right now.Registration is fast and FREE... Join Now!



Assignment #2 - Display message based on time of day JavaScript

#1 skyhawk133  Icon User is offline

  • Head DIC Head
  • Icon

Reputation: 619
  • View blog
  • Posts: 18,430
  • Joined: 17-March 01


Dream Kudos: 1650

Expert In: Web Development

Share |

Assignment #2 - Display message based on time of day

Posted 29 August 2001 - 07:41 AM

The scenario for this was to take a pre-done page and put some script in to show a message based on the time of day... Keep in mind the hours are based on 24, not like 8:00PM...Here is the JS script:
<SCRIPT LANGUAGE="Javascript">
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!")
  }

</SCRIPT>

Here is the actual page: http://w3.tvi.cc.nm....kyhawk/cp132/j2

Was This Post Helpful? 0
  • +
  • -


#2 codeman  Icon User is offline

  • w3c fanatic
  • PipPipPipPipPip

Reputation: 3
  • View blog
  • Posts: 1,190
  • Joined: 12-August 01

Re: Assignment #2 - Display message based on time of day

Posted 29 August 2001 - 08:37 AM

uh....I don't see the script on the page.  I'm using IE 5.5 so is it for Netscape or something? :)
Was This Post Helpful? 0
  • +
  • -

#3 LeprechauN  Icon User is offline

  • D.I.C Addict
  • Icon

Reputation: 1
  • View blog
  • Posts: 857
  • Joined: 12-March 01


Dream Kudos: 10

Re: Assignment #2 - Display message based on time of day

Posted 29 August 2001 - 09:45 AM

"Welcome to Carbon Copy Printers. Good afternoon. We can get that print job ready by tomorrow morning. We are open 24 hours a day. No job is too big or too small."

It returns the message acording to your current time.

Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users