• Jueves 28 de Marzo de 2024, 18:14

Autor Tema:  Ayud Cronometro decreciente  (Leído 1738 veces)

collado

  • Nuevo Miembro
  • *
  • Mensajes: 2
    • Ver Perfil
Ayud Cronometro decreciente
« en: Domingo 23 de Noviembre de 2008, 12:23 »
0
Hola.

Tengo el codigo scrip de un cronometro que empieza desde 0, y estoy intentando programarlo para que empieze desde 2:00:00 hasta 0:0:0.

Al final no he podido conseguir que funcione, os dejo el codigo para que alguien me ayude y me explique que tengo que cambiar, me gustaria hacerlo decreciente desde el minuto 2 y otro desde el minuto 1.

Gracias de antemano

Codigo:

<html>

<head>
<SCRIPT LANGUAGE="Javascript1.2">
<!-- begin hide
var currentsec=0;   // initilize variables
var currentmin=0;   // to zero
var currentmil=0;
var keepgoin=false;      // keepgoin is false
function timer(){
 if(keepgoin){
  currentmil+=1;      // add incretement
   if (currentmil==10){      // if miliseconds reach 10
    currentmil=0;      // Change miliseconds to zero
    currentsec+=1;      // and add one to the seconds variable
   }
   if (currentsec==60){      // if seconds reach 60
    currentsec=0;      // Change seconds to zero
    currentmin+=1;      // and add one to the minute variable
   }
  Strsec=""+currentsec;      // Convert to strings
  Strmin=""+currentmin;      // Convert to strings
  Strmil=""+currentmil;      // Convert to strings
   if (Strsec.length!=2){   // if seconds string is less than
    Strsec="0"+currentsec;   // 2 characters long, pad with leading
   }            // zeros
   if (Strmin.length!=2){   // Same deal here with minutes
    Strmin="0"+currentmin;
   }
  document.display.seconds.value=Strsec      // displays times
  document.display.minutes.value=Strmin;   // here
  document.display.milsecs.value=Strmil;
  setTimeout("timer()", 100);   // waits one second and repeats
 }
}
function startover(){      // This function resets
keepgoin=false;         // all the variables
currentsec=0;
currentmin=0;
currentmil=0;
Strsec="00";
Strmin="00";
Strmil="00";
}
//--end hide -->
</SCRIPT>
<base target="contenido">
</head>

<body bgcolor="#C0C0C0">
<center>

          <table align="center" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
            <tr>
              <td width="10%">
              &nbsp;</td>
<td width="80%">

<CENTER>

   <FORM NAME="display" ONRESET="startover()">
      <TABLE BORDER=10 BGCOLOR="#9999CC" bordercolor="#ccccff" bordercolordark="#9999CC" width="278" height="80" style="border-collapse: collapse" cellpadding="0" cellspacing="0">
         <TR><TD BGCOLOR="#000000" COLSPAN=3 width="324" height="64">
            <DIV STYLE="font-size:35px;font-family:LCD,Sans Serif;color:#ffff00">
            <p align="center">&nbsp;<INPUT TYPE="text" NAME="minutes" VALUE="00" SIZE=3 STYLE="height:54;border:0px none;font-size:45px;width:54;font-family:LCD,Sans Serif;color:#ffff00;background:#000000">
            :
            <INPUT TYPE="text" NAME="seconds" VALUE="00" SIZE=3 STYLE="height:54;border:0px none;font-size:45px;width:54;font-family:LCD,Sans Serif;color:#ffff00;background:#000000">
            :
            <INPUT TYPE="text" NAME="milsecs" VALUE="0" SIZE=3 STYLE="height:54;border:0px none;font-size:45px;width:54;font-family:LCD,Sans Serif;color:#ffff00;background:#000000">
            </TD></TR><TR><TD CELLPADDING=5 width="66" height="4">
            <p align="center">
            <INPUT TYPE="button" NAME="start" VALUE="Inicio" ONCLICK="keepgoin=true;timer()" style="float: left">
            </TD><TD width="192" height="4">
            <p align="center">
            <INPUT TYPE="button" NAME="pause" VALUE="Pausa" ONCLICK="keepgoin=false;">
            </TD><TD width="66" height="4">
            <p align="center">
            <INPUT TYPE="reset" NAME="reset" VALUE="Borrar" style="float: right">
         </TD></TR>
      </TABLE>
   </FORM>

</CENTER>


</td>
              <td width="10%" align="left">
              &nbsp;</td>
            </tr>
            </table>
          </center>
       
</body>

</html>

collado

  • Nuevo Miembro
  • *
  • Mensajes: 2
    • Ver Perfil
Re: Ayud Cronometro decreciente
« Respuesta #1 en: Viernes 28 de Noviembre de 2008, 18:00 »
0
Nadie me puede ayudarrrrrrrrrrrrr