Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts

    Exclamation Why does this supplied code not work?

    I have put this code together from a tuition site, but I cannot get it to work.
    Some of the instructions were ambiguous so I may have done it wrong.(the story of my life.) Any help gratefully received.

    Frank alias effpeetee.

    Code:
    <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <script type="text/javascript">
    function clock(){
      var time = new Date()
      var hr = time.getHours()
      var min = time.getMinutes()
      var sec = time.getSeconds()
      if(hr < 10){
        hr = " " + hr
        }
      if(min < 10){
        min = "0" + min
        }
      if(sec < 10){
        sec = "0" + sec
        } 
      document.clock.digits.value = hr + ":" + min + ":" + sec
      setTimeout("clock()", 1000)
      }
    </script>
    </head>
    <body >
    <script type="text/javascript>
    onLoad = "clock()"
    </script>
    
    <FORM name="clock">
     <FONT face="Courier New,Courier" size=4>
     <INPUT type="text"  name="digits"
        size=8 maxlength=8 value="Loading">
     </FONT>
     </FORM>
    </body>
    </html>
    Last edited by effpeetee; 06-23-2009 at 02:08 PM.
    * Sources (updated: 21.11.2012.
    Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.

  • #2
    Regular Coder
    Join Date
    May 2008
    Posts
    135
    Thanks
    13
    Thanked 10 Times in 10 Posts
    Code:
    <script type="text/javascript>
    onLoad = "clock()"
    </script>
    this here aint doing anything. try this

    Code:
    <body onload="clock()">
    so when the body loads, execute the clock function

  • #3
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts
    Thanks mike182uk,

    I thought that was probably one of the parts I did not quite understand. Your modification works perfectly. Many thanks.
    Up until now, I have been a cut and paste (pinch someone elses code) man.
    I am trying to come to terms with javascript.

    Back to the grindstone.

    Frank
    * Sources (updated: 21.11.2012.
    Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.

  • #4
    Regular Coder
    Join Date
    May 2008
    Posts
    135
    Thanks
    13
    Thanked 10 Times in 10 Posts
    We all have to start somewhere :-)

  • #5
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts
    Quote Originally Posted by mike182uk View Post
    We all have to start somewhere :-)
    I am 84 yrs old in September.
    Perhaps I have left it a bit late.

    but -

    Nil desperandum.

    Nothing ventured, nothing gained.

    Frank - alias effpeetee
    Last edited by effpeetee; 06-23-2009 at 02:15 PM.
    * Sources (updated: 21.11.2012.
    Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.


  •  

    Posting Permissions

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