Ver Mensaje Individual
  #2 (permalink)  
Antiguo 03/08/2009, 14:45
Avatar de alor86
alor86
 
Fecha de Ingreso: abril-2009
Mensajes: 110
Antigüedad: 15 años
Puntos: 5
Respuesta: como hacer un contador inverso en boton

preuba con esto a ver si te funciona
Código javascript:
Ver original
  1. <html>
  2.  
  3. <head>
  4.    
  5.     <script type="text/javaScript">
  6.         var interval;
  7.         var c = 13;
  8.         function cuenta(){
  9.             interval = setInterval(iniciar,1000);
  10.         }
  11.         function iniciar(){
  12.             if(c>0){
  13.                 c--;
  14.                 document.getElementById("b1").value=c;
  15.             }
  16.             else{
  17.                 document.getElementById("b1").value="iniciar";
  18.                 document.getElementById("b1").disabled=false;
  19.                 clearInterval(interval);
  20.             }
  21.         }
  22.     </script>
  23.     <title>Untitled 1</title>
  24. </head>
  25.  
  26. <body onload="cuenta()">
  27. <input type="button" value="13" id="b1" disabled="" style="width:100px;color:#000">
  28.  
  29.  
  30. </body>
  31. </html>