Foros del Web » Programando para Internet » Javascript »

script del reloj ponerlo en un input

Estas en el tema de script del reloj ponerlo en un input en el foro de Javascript en Foros del Web. <SCRIPT> var tick; function stop() { clearTimeout(tick); } function simple_reloj() { var ut=new Date(); var h,m,s; var time=" "; h=ut.getHours(); m=ut.getMinutes(); s=ut.getSeconds(); if(s<=9) s="0"+s; if(m<=9) ...
  #1 (permalink)  
Antiguo 11/05/2011, 12:19
 
Fecha de Ingreso: abril-2011
Ubicación: parral
Mensajes: 16
Antigüedad: 13 años
Puntos: 0
Exclamación script del reloj ponerlo en un input

<SCRIPT>
var tick;
function stop() {
clearTimeout(tick);
}
function simple_reloj() {
var ut=new Date();
var h,m,s;
var time=" ";
h=ut.getHours();
m=ut.getMinutes();
s=ut.getSeconds();
if(s<=9) s="0"+s;
if(m<=9) m="0"+m;
if(h<=9) h="0"+h;
time+=h+":"+m+":"+s;
document.getElementById('reloj').innerHTML=time;
tick=setTimeout("simple_reloj()",1000);
}
</SCRIPT>

<body onLoad="simple_reloj();" onUnload="stop();">
<form name="form_reloj">
<p><span id="reloj" name="relo">reloj</span>
</form>
</body>

Este es el codigo pero quiero poner el reloj en un input no en un span como se haria gracias!!
  #2 (permalink)  
Antiguo 11/05/2011, 12:24
Avatar de leo_nqn  
Fecha de Ingreso: abril-2010
Ubicación: Neuquen
Mensajes: 461
Antigüedad: 14 años
Puntos: 24
Respuesta: script del reloj ponerlo en un input

<input tipe="text" name="relo" value=reloj /> probaste asi?
__________________

Blog: http://leonardonqn.blogspot.com
Twitter:@Leo_FFerreyra
  #3 (permalink)  
Antiguo 11/05/2011, 12:35
 
Fecha de Ingreso: abril-2011
Ubicación: parral
Mensajes: 16
Antigüedad: 13 años
Puntos: 0
Respuesta: script del reloj ponerlo en un input

si pero no me sale el reloj en el input me sale reloj en ves de la hora
  #4 (permalink)  
Antiguo 11/05/2011, 12:41
Avatar de leo_nqn  
Fecha de Ingreso: abril-2010
Ubicación: Neuquen
Mensajes: 461
Antigüedad: 14 años
Puntos: 24
Respuesta: script del reloj ponerlo en un input

si disculpa te pase cualquier cosa... toma.. el script te quedaria asi:

Código:
<SCRIPT>
var tick;
function stop() {
clearTimeout(tick);
}
function simple_reloj() {
var ut=new Date();
var h,m,s;
var time=" ";
h=ut.getHours();
m=ut.getMinutes();
s=ut.getSeconds();
if(s<=9) s="0"+s;
if(m<=9) m="0"+m;
if(h<=9) h="0"+h;
time+=h+":"+m+":"+s;
document.getElementById('reloj').innerHTML=time;
tick=setTimeout("simple_reloj()",1000);
document.form_reloj.relo.value=time; 
}
</SCRIPT>
y en el formulario agrega esto:

Código:
<input type="text" id="reloj" name="relo" />
lo del body dejalo como estaba.. espero te sirva saludos!
__________________

Blog: http://leonardonqn.blogspot.com
Twitter:@Leo_FFerreyra
  #5 (permalink)  
Antiguo 11/05/2011, 13:04
 
Fecha de Ingreso: abril-2011
Ubicación: parral
Mensajes: 16
Antigüedad: 13 años
Puntos: 0
Respuesta: script del reloj ponerlo en un input

si me sirvio cuando lo pongo asi como esta pero cuandolo pongo en una tabla ya no jala
asi esta mi tabla:
<head>
<style type="text/css">
.style1 {
text-align: center;
}
</style>
</head>
<SCRIPT>
var tick;
function stop() {
clearTimeout(tick);
}
function simple_reloj() {
var ut=new Date();
var h,m,s;
var time=" ";
h=ut.getHours();
m=ut.getMinutes();
s=ut.getSeconds();
if(s<=9) s="0"+s;
if(m<=9) m="0"+m;
if(h<=9) h="0"+h;
time+=h+":"+m+":"+s;
document.getElementById('reloj').innerHTML=time;
tick=setTimeout("simple_reloj()",1000);
document.form_reloj.relo.value=time;
}
</SCRIPT>
<?php
require 'inicio.php';
require 'conexion.php';
include 'auth.php';
$gropid = $_REQUEST['gropid'];
$gruposql = "SELECT nombre, ap_pat, ap_mat, matricula FROM personal WHERE matricula='$gropid' ";
$result = mysql_query($gruposql) or die("Invalid query: " . mysql_error());
while ($row = mysql_fetch_array($result)) {
extract($row);
?>
<center>
<form method="post" action="datos_personal_sql.php">
<table style="width: 51%">
<tr><TD BGCOLOR="#08088A" style="width: 181px; height: 22px"><label>Id</label></td>
<TD BGCOLOR="#ddd9d3" style="width: 232px; height: 22px"><?php echo $matricula;?><Input type="hidden" name="mat" value="<?php echo $matricula;?>" />
</td>
<tr><TD BGCOLOR="#08088A" style="width: 181px; height: 22px"><label>Nombre</label></td>
<TD BGCOLOR="#ddd9d3" style="width: 232px; height: 22px"><?php echo $nombre;?><Input type="hidden" name="nom" value="<?php echo $nombre;?>" />
</td>
</tr>
<tr>
<TD BGCOLOR="#08088A" style="width: 181px"><label>Apellido Paterno</label></td>
<TD BGCOLOR="#ddd9d3" style="width: 232px"><?php echo $ap_pat;?><Input type="hidden" name="apat" value="<?php echo $ap_pat;?>" /></td>
</tr>
<tr>
<TD BGCOLOR="#08088A" style="width: 181px"><label>Apellido Materno</label></td>
<TD BGCOLOR="#ddd9d3" style="width: 232px"><?php echo $ap_mat;?><Input type="hidden" name="apmat" value="<?php echo $ap_mat;?>"/></td>
</tr><tr><TD BGCOLOR="#08088A" style="width: 181px"><label>Turno</label></td>
<TD BGCOLOR="#ddd9d3" style="width: 232px"><select name="turn"><option value="1">Matutino</option><option value="2">Vespertino</option></select></td>
</tr><tr>
<TD BGCOLOR="#08088A" style="width: 181px"><label>Fecha</label></td>
<TD BGCOLOR="#ddd9d3" style="width: 232px"><?php $hoy=date("d/m/Y"); ?><Input type="text" name="fech" value="<?php echo $hoy;?>"></td>
</tr><tr>
<TD BGCOLOR="#08088A" style="width: 181px"><label>Hora</label></td>
<TD BGCOLOR="#ddd9d3" style="width: 232px">
<body onLoad="simple_reloj();" onUnload="stop();">
<form1 name="form_reloj">
<input type="text" id="reloj" name="relo">
</form1>
</body>
</tr><tr>
<TD BGCOLOR="#08088A" style="width: 181px"><label>Asistencia</label></td>
<TD BGCOLOR="#ddd9d3" style="width: 232px"><input type="checkbox" name="recibido"></td>
</tr>
<tr>
<TD BGCOLOR="#ddd9d3" style="width: 181px" class="style1"><input type="submit" name="action" value="Guardar"/></td>
<td BGCOLOR="#ddd9d3" style="width: 181px" class="style1"><a href="control_personal.php"><input type="button" name="action" value="Regresar"/></a></td>
</tr>
</form>
</table>
  #6 (permalink)  
Antiguo 11/05/2011, 13:05
Avatar de leo_nqn  
Fecha de Ingreso: abril-2010
Ubicación: Neuquen
Mensajes: 461
Antigüedad: 14 años
Puntos: 24
Respuesta: script del reloj ponerlo en un input

bueno amigo pero vos queres la chancha y los 20...
__________________

Blog: http://leonardonqn.blogspot.com
Twitter:@Leo_FFerreyra
  #7 (permalink)  
Antiguo 11/05/2011, 13:15
Avatar de leo_nqn  
Fecha de Ingreso: abril-2010
Ubicación: Neuquen
Mensajes: 461
Antigüedad: 14 años
Puntos: 24
Respuesta: script del reloj ponerlo en un input

te falta en <form name="form_reloj">

name=form_reloj eso te falta!

mas atencion!
__________________

Blog: http://leonardonqn.blogspot.com
Twitter:@Leo_FFerreyra
  #8 (permalink)  
Antiguo 11/05/2011, 14:00
 
Fecha de Ingreso: abril-2011
Ubicación: parral
Mensajes: 16
Antigüedad: 13 años
Puntos: 0
Respuesta: script del reloj ponerlo en un input

ya le puse el form y no me jala no se porque no me esta funcionando

Etiquetas: input, php, reloj
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:16.