View Full Version : stopwatch

12-16-2010, 05:30 AM
hi everyone, I am currently working on a stopwatch and I can't for the life of me get it inside this textbox.. Can anyone help with it? no matter what I seem to try it always goes outside of it...

<title> stopwatch </title>
<script type="text/javascript">

var setT, h, m, s;

function startWatch(b){
var ticker=document.getElementById('ticker');
var HH=h<10?'0'+h:h;
var MM=m<10?'0'+m:m;
var SS=s<10?'0'+s:s;
ticker.innerHTML = HH+':'+MM+':'+SS;

function stopWatch(){

function resetWatch(){
h=0; m=0; s=0;



<form action="">

<input type="button" value="start clock" onclick="startWatch(true)">
<input type="button" value="stop clock" onclick="stopWatch()">
<input type="button" value="reset clock" onclick="resetWatch()">
<span id="ticker"></span>

<INPUT type="text" id="ticker">

Logic Ali
12-16-2010, 06:03 AM
You have two elements with the same ID.
You need to write to the .value property of the text box not innerHTML.

Old Pedant
12-16-2010, 07:03 AM
LOL! How funny!!!!

The setTimeout is 50. That's 50 milliseconds.

And EVERY TIME startWatch is called, it increments the time by ONE SECOND!!!

So the "stop watch" is runing 20 times too fast!!!! (20 times 50ms == 1000ms == 1second).

That's not a "StopWatch". That's a "FastWatch".

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum