Javascript Help

Discussion in 'HTML & Website Design' started by ClopinTrouillefou, Nov 17, 2007.

  1. #1
    I have a problem with my code and i don't know what's wrong with it... :( :confused:

    I got it working before using the time off the computer, But I need it to start from 0 kinda like a stop watch.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
    <HTML>
    <HEAD>
    <TITLE></TITLE>
    <META NAME="Generator" CONTENT="TextPad 4.4">
    <META NAME="Author" CONTENT="?">
    <META NAME="Keywords" CONTENT="?">
    <META NAME="Description" CONTENT="?">
    <script language="javascript">
    
    function start_clock(){
    
       var x=new Date()
    
       var hh=x.getUTCHours()
       var mm=x.getUTCMinutes()
       var ss=x.getUTCSeconds()
    
     if(hh<10){
          hh="0"+hh
    
       }
    
        if(mm<10){
             mm="0"+mm
    
          }
    
     if(ss<10){
          ss="0"+ss
    
       }
    
    
       document.f1.tb1.value = "" + new Date.getUTCHours() 
    + ":"+ new Date.getUTCMinutes() + ":" + new Date.getUTCSeconds();
    
    
    
    
    
    }
    
    function stop_clock(){
    
       clearTimeout(timer)
    
    }
    
    </script>
    </HEAD>
    
    <BODY BGCOLOR="#FFFFFF" TEXT="#000000" 
    LINK="#FF0000" VLINK="#800000" ALINK="#FF00FF" BACKGROUND="?">
    
    <form name="f1">
    
    <input type="text" name="tb1"/>
    
    <input type="button" value="Start" name="start" onClick="start_clock()"/>
    
    <input type="button" value="Stop" name="stop" onClick="stop_clock()"/>
    
    </form>
    </BODY>
    </HTML>
    
    Code (markup):
    Can anyone help me? :confused:
     
    ClopinTrouillefou, Nov 17, 2007 IP
  2. Robert T

    Robert T Peon

    Messages:
    105
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    java-scripts.net/javascripts/Stop-Watch-Script.phtml
     
    Robert T, Nov 17, 2007 IP