SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Dec 2003
    Location
    spain
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript question

    I am unable to get the result of this simple writing in javascript; thatīs it, doesnīt turn up a box containing "Good Morning".

    <html>
    <body>
    <script type= "text/javascript">
    var d = new Date ()
    var time= d.getHours ()
    if (time > 18)
    {
    document.write ("<b>Good Morning</b>")
    }
    </script>
    </body>
    </html>

  2. #2
    Word Painter silver trophy Shyflower's Avatar
    Join Date
    Oct 2003
    Location
    Winona, MN USA
    Posts
    10,053
    Mentioned
    142 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by mike1
    I am unable to get the result of this simple writing in javascript; thatīs it, doesnīt turn up a box containing "Good Morning".

    <html>
    <body>
    <script type= "text/javascript">
    var d = new Date ()
    var time= d.getHours ()
    if (time > 18)
    {
    document.write ("<b>Good Morning</b>")
    }
    </script>
    </body>
    </html>
    maybe a dumb question, but have you tried it after 6p.m.? It should work then.
    Linda Jenkinson
    "Say what you mean. Mean what you say. But don't say it mean." ~Unknown

  3. #3
    . Ruchir's Avatar
    Join Date
    Feb 2002
    Location
    Sydney
    Posts
    1,863
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yep, the script will not work until the time is past 7 in the evening.. so, just change the condition for time in the syntax !

    -ruchir
    Peace.

  4. #4
    SitePoint Member
    Join Date
    Dec 2003
    Location
    spain
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It was right! Thank you.

  5. #5
    Word Painter silver trophy Shyflower's Avatar
    Join Date
    Oct 2003
    Location
    Winona, MN USA
    Posts
    10,053
    Mentioned
    142 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by mike1
    It was right! Thank you.
    No problem. Just remember that < means "is less than" and > means "is greater than" *s*
    Linda Jenkinson
    "Say what you mean. Mean what you say. But don't say it mean." ~Unknown

  6. #6
    SitePoint Member
    Join Date
    Oct 2003
    Location
    Melbourne, Australia
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    todaydate = new Date();
    timeis=todaydate.getTime();
    todaydate.setTime(timeis);
    houris = todaydate.getHours();
    if (houris > 17) display = "Evening";
    else if (houris >12) display = "Afternoon";
    else display = "Morning";
    var welcome = ("Good " + display + "," );
    document.writeln("<b><font size=2 font color='blue' face='Comic Sans MS'>");
    document.writeln("<b>");
    document.write(welcome);document.writeln("<br>");

    // End -->
    </script>

    you can change font size and color and font face


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •