Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. is there any mistake in code

is there any mistake in code

Scheduled Pinned Locked Moved JavaScript
javascripthtmltools
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hotthoughtguy
    wrote on last edited by
    #1

    <html> <body> <script type="text/javascript"> var date = new Date(); var time = date.getHours(); if (time > 12 ) { document.write("<b>Good Afternoon</b>"); } if (time > 17 && < 24) { document.write("<b>Good Evening</b>"); } else { document.write("<b>Good Morning</b>"); } </script> </body> </html> output is a blank page

    N L 2 Replies Last reply
    0
    • H hotthoughtguy

      <html> <body> <script type="text/javascript"> var date = new Date(); var time = date.getHours(); if (time > 12 ) { document.write("<b>Good Afternoon</b>"); } if (time > 17 && < 24) { document.write("<b>Good Evening</b>"); } else { document.write("<b>Good Morning</b>"); } </script> </body> </html> output is a blank page

      N Offline
      N Offline
      NeverHeardOfMe
      wrote on last edited by
      #2

      if (time > 17 && < 24) should be if (time > 17 && time < 24) (apart from which, as it is, it will write bnth Good Afternoon and Good Morning...) May I suggest you use Firefox and open the error concole (Tools menu) - this will highlight such erros immediately and greatly help you in debugging your JavaScript code

      1 Reply Last reply
      0
      • H hotthoughtguy

        <html> <body> <script type="text/javascript"> var date = new Date(); var time = date.getHours(); if (time > 12 ) { document.write("<b>Good Afternoon</b>"); } if (time > 17 && < 24) { document.write("<b>Good Evening</b>"); } else { document.write("<b>Good Morning</b>"); } </script> </body> </html> output is a blank page

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        I think the statement

        if (time > 17 && < 24)

        should read

        if (time > 17 && time < 24)

        Just say 'NO' to evaluated arguments for diadic functions! Ash

        H 1 Reply Last reply
        0
        • L Lost User

          I think the statement

          if (time > 17 && < 24)

          should read

          if (time > 17 && time < 24)

          Just say 'NO' to evaluated arguments for diadic functions! Ash

          H Offline
          H Offline
          hotthoughtguy
          wrote on last edited by
          #4

          thanks bro its working now

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups