
Problema con click en un checkbox
Publicado por Carlos Lozada (3 intervenciones) el 31/01/2011 16:05:03
Hola Compañeros mi problema es el siguiente, lo que necesito es q al darle click en un checkbox
me aparesca la hora y la fecha y si le doy de nuevo click desaparesca y la verdad no se como menejar esta funcion
Este es mi codigo:
<html>
<head>
<title>Hora y Fecha</title>
<script language="JavaScript">
function HoraFecha(){
momentoActual = new Date()
hora = momentoActual.getHours()
minuto = momentoActual.getMinutes()
segundo = momentoActual.getSeconds()
dia = momentoActual.getDate()
mes = momentoActual.getMonth() + 1
año = momentoActual.getFullYear()
str_segundo = new String (segundo)
if (str_segundo.length == 1)
segundo = "0" + segundo
str_minuto = new String (minuto)
if (str_minuto.length == 1)
minuto = "0" + minuto
str_hora = new String (hora)
if (str_hora.length == 1)
hora = "0" + hora
var horas1 = document.formulario.HoraYFecha.value;
if(horas1 == click)
{
Imprime = dia + "-" + mes + "-" + año + " " + hora + " : " + minuto + " : " + segundo
document.formulario.ingreso.value = Imprime
document.formulario.ingreso.value.disabled = true
}
setTimeout("HoraFecha()",1000)
}
</script>
</head>
<body onLoad="HoraFecha()">
<form name="formulario">
<input type="text" name="ingreso" size="17" ><input name="HoraYFecha" type="checkbox" onClick="window.document.formulario.ingreso.blur()">
</form>
</body>
</html>
me aparesca la hora y la fecha y si le doy de nuevo click desaparesca y la verdad no se como menejar esta funcion
Este es mi codigo:
<html>
<head>
<title>Hora y Fecha</title>
<script language="JavaScript">
function HoraFecha(){
momentoActual = new Date()
hora = momentoActual.getHours()
minuto = momentoActual.getMinutes()
segundo = momentoActual.getSeconds()
dia = momentoActual.getDate()
mes = momentoActual.getMonth() + 1
año = momentoActual.getFullYear()
str_segundo = new String (segundo)
if (str_segundo.length == 1)
segundo = "0" + segundo
str_minuto = new String (minuto)
if (str_minuto.length == 1)
minuto = "0" + minuto
str_hora = new String (hora)
if (str_hora.length == 1)
hora = "0" + hora
var horas1 = document.formulario.HoraYFecha.value;
if(horas1 == click)
{
Imprime = dia + "-" + mes + "-" + año + " " + hora + " : " + minuto + " : " + segundo
document.formulario.ingreso.value = Imprime
document.formulario.ingreso.value.disabled = true
}
setTimeout("HoraFecha()",1000)
}
</script>
</head>
<body onLoad="HoraFecha()">
<form name="formulario">
<input type="text" name="ingreso" size="17" ><input name="HoraYFecha" type="checkbox" onClick="window.document.formulario.ingreso.blur()">
</form>
</body>
</html>
Valora esta pregunta


0