View Full Version : stopwatch

05-02-2006, 11:52 PM
if i try to make a stop watch with this simple code:

var seconds = 0
var minutes = 0
function custom(){
if (seconds<60){
minutes = minutes
seconds = parseFloat(seconds)+parseFloat(1)
else if (seconds==59){
minutes = parseFloat(minutes)+parseFloat(1)
seconds = 0
if (seconds<10){
seconds = "0"+seconds
document.byu.cougar.value = minutes+":"+seconds

then how can i make the STOPwatch STOP?!?

Philip M
05-03-2006, 08:36 AM
Presumably you need to stop, start and reset. This should do the trick.


If you want seconds rather than milliseconds change the three instances of
document.stpw.time.value = ms;
document.stpw.time.value = ms/1000;

or if you want to show whole seconds only
document.stpw.time.value = Math.round(ms/1000);