Ver Mensaje Individual
  #4 (permalink)  
Antiguo 25/02/2011, 10:18
omarMusic
 
Fecha de Ingreso: febrero-2011
Ubicación: Evolandia
Mensajes: 103
Antigüedad: 13 años, 2 meses
Puntos: 10
Respuesta: Problema cronometro en javascript

Si simplemente deshabilitas el botón después de ejecutarlo por primera vez, o sea cuando ms este en 0, también habria q inicializar los datos cada vez q se refresque a 0, algo así

Código Javascript:
Ver original
  1. function iniciar(e){
  2.     var start=document.getElementById('start');
  3.     document.getElementById('ms').value = 0;
  4.     document.getElementById('s').value = 0;
  5.     document.getElementById('start').disabled = false;
  6.     start.addEventListener('click',crono,false)
  7. }
  8.  
  9. function crono(e){
  10.     var ms=document.getElementById('ms')
  11.     var m=document.getElementById('m')
  12.     var s=document.getElementById('s')
  13.     if (ms.value == "0")
  14.         document.getElementById('start').disabled = true;
  15.     ms.value++;
  16.     if(ms.value>=99){
  17.     s.value++;
  18.     ms.value=00
  19.     }
  20.     setTimeout('crono()',10)
  21. }

también q el buton sea un input type="button" para q funcione correctamente

Saludos!