Ver Mensaje Individual
  #4 (permalink)  
Antiguo 24/06/2010, 14:53
Avatar de Adler
Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 17 años, 3 meses
Puntos: 126
Respuesta: Como Insertar hora similiar a calendario fecha

Hola

A ver si es esto lo que buscas

Código Javascript:
Ver original
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <script type="text/javascript">
  5. var milsegundos = 0;
  6.  
  7. var ns4 = (document.layers)? true:false
  8. var ie4 = (document.all)? true:false
  9. var ns6 = (document.getElementById)? true:false
  10. function captura_objeto(idnombre) {
  11.     if (ns6)
  12.     {
  13.     return document.getElementById(idnombre);
  14.     }
  15.     else if (ie4)
  16.     {
  17.     return document.all[idnombre];
  18.     }
  19.     else if (ns4)
  20.     {
  21.     return document.layers[idnombre];
  22.     }
  23.     else
  24.     {
  25.     return null;
  26.     }
  27. }
  28.  
  29.  
  30.  
  31. function muestraReloj() {
  32. var fechacompleta = new Date();
  33. var horas = fechacompleta.getHours();
  34. var minutos = fechacompleta.getMinutes();
  35. var segundos = fechacompleta.getSeconds();
  36. var hmisengundos = horas*60*60*1000;
  37. var mmisengundos = minutos*60*1000;
  38. var smisengundos = segundos*1000;
  39. milsegundos = hmisengundos + mmisengundos + smisengundos;
  40. if (minutos <= 9) minutos = "0" + minutos;
  41. if (segundos <= 9) segundos = "0" + segundos;
  42. intervalo = setTimeout("muestraReloj(), 1000");
  43. captura_objeto("reloj").value = horas + ":" + minutos + ":" + segundos;
  44. }
  45.  
  46.  
  47. function VariarHora (accion) {
  48. clearTimeout(intervalo);
  49. if (accion == 'restar'){milsegundos -= 1000;}
  50. if (accion == 'sumar'){milsegundos += 1000;}
  51. segundostotales = parseInt(milsegundos/1000);
  52. minutostotales = parseInt(segundostotales/60);
  53. horas = parseInt(minutostotales/60);
  54. minutos = parseInt(minutostotales &#37; 60);
  55. segundos = parseInt(segundostotales % 60);
  56. if (minutos <= 9) minutos = "0" + minutos;
  57. if (segundos <= 9) segundos = "0" + segundos;
  58. captura_objeto("reloj").value = horas + ":" + minutos + ":" + segundos;
  59. }
  60. </script>
  61. </head>
  62. <body onLoad="muestraReloj()">
  63. <input type="text" id="reloj" value="" />
  64. <input type="button" onclick="VariarHora('sumar')" value="+" />
  65. <input type="button" onclick="VariarHora('restar')" value="-" />
  66. </body>
  67. </html>

Suerte
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />