Foros del Web » Programando para Internet » Javascript »

ayuda con este codigo

Estas en el tema de ayuda con este codigo en el foro de Javascript en Foros del Web. Código HTML: <html> <head> <title> </title> <script> function algo(bot) { do bot = bot.parentNode while (bot.tagName != 'TR') for(i=0; ele = bot.getElementsByTagName('input')[i]; i++) ele.readOnly = ...
  #1 (permalink)  
Antiguo 23/06/2005, 16:20
 
Fecha de Ingreso: octubre-2004
Ubicación: chile
Mensajes: 116
Antigüedad: 19 años, 6 meses
Puntos: 0
ayuda con este codigo

Código HTML:
<html>
<head>
<title></title>
<script>
function algo(bot) { 
  do bot = bot.parentNode 
   while (bot.tagName != 'TR') 
  for(i=0; ele = bot.getElementsByTagName('input')[i]; i++) 
    ele.readOnly = false; 
} 
</script>
</head>
<body>
<table border="1">
<tr>
  <td>id</td>
	<td>nº Matricula</td>
	<td>Alumno</td>
	<td>sol 1</td>
  <td>sol 2</td>
	<td>ctrl 1</td>
	<td>ctrl 2</td>
	<td>ctrl 3</td>
	<td>ctrl 4</td>
	<td>Examen</td>
	<td>Final</td>
</tr>

<? foreach ($datos as $us) 
{?>
<tr>  
	<td align="center"><?=$us['id'];?></td>
	<td align="center"><?=$us['n_matricula'];?></td>
	<td align="center"><?=$us['alumno_nom'];?> <?$us['alumno_nom'];?></td>
	<td align="center"><input type="text" size="1" readonly="readonly" value="<?=$us['sol1'];?>"</td>
  <td align="center"><input type="text" size="1" readonly="readonly" value="<?=$us['sol2'];?>"</td>
	<td align="center"><input type="text" size="1" readonly="readonly" value="<?=$us['ctrl1'];?>"</td>
	<td align="center"><input type="text" size="1" readonly="readonly" value="<?=$us['ctrl2'];?>"</td>
	<td align="center"><input type="text" size="1" readonly="readonly" value="<?=$us['ctrl3'];?>"</td>
	<td align="center"><input type="text" size="1" readonly="readonly" value="<?=$us['ctrl4'];?>"</td>
	<td align="center"><input type="text" size="1" readonly="readonly" value="<?=$us['examen'];?>"</td>
	<td align="center"><?=promedio($us['sol1'], $us['sol2'], $us['ctrl1'], $us['ctrl2'], $us['ctrl3'], $us['ctrl4'], $us['examen']);?></td>
  <td align="center"><input type="button" name="Editar" value="Editar" onclick="habilitar()"></td> 
</tr>
<? } ?>
</table>
</body>
</html> 
el problema es ke al apretar el boton editar deberian habilitarse los input text para escritura, pero al ahcerlo no sucede nada, todos los input text siguen iguales
  #2 (permalink)  
Antiguo 23/06/2005, 20:32
Avatar de SiR.CARAJ0DIDA  
Fecha de Ingreso: junio-2004
Ubicación: Acá
Mensajes: 1.166
Antigüedad: 19 años, 10 meses
Puntos: 4
y donde esta la funcion habilitar??

hace asi a ver:

o = document.getElementsByTagName('input');
for (i=0;i<o.length;i++)
{
o[i].readonly = false;
}

pero creo que deberias usar el atributo DISABLED.
  #3 (permalink)  
Antiguo 23/06/2005, 20:44
 
Fecha de Ingreso: octubre-2004
Ubicación: chile
Mensajes: 116
Antigüedad: 19 años, 6 meses
Puntos: 0
no funciona lo apreto y siguen iguales no se habilitan

y como se haria con disabled???? si lo k kiero hacer es ke al apretar el bton editar se pueda cambiar el valor del input, ahora el como...me da lo mismo

grax
  #4 (permalink)  
Antiguo 23/06/2005, 20:58
Avatar de SiR.CARAJ0DIDA  
Fecha de Ingreso: junio-2004
Ubicación: Acá
Mensajes: 1.166
Antigüedad: 19 años, 10 meses
Puntos: 4
hay un error en los input, te falta el tag de cierre, proba asi

<input type="text" size="1" value="<?=$us['ctrl1'];?>" disabled>

o = document.getElementsByTagName('input');
for (i=0;i<o.length;i++)
{
if (o[i].type == "text") o[i].disabled = false;
}
  #5 (permalink)  
Antiguo 23/06/2005, 21:20
 
Fecha de Ingreso: octubre-2004
Ubicación: chile
Mensajes: 116
Antigüedad: 19 años, 6 meses
Puntos: 0
no hay caso apreto y apreto el boton y no se habilitan :(

la funcion kedo asi

Código PHP:
<script>

function 
habilitar()
{
  
document.getElementsByTagName('input');
  for (
i=0;i<o.length;i++)
  {
    
o[i].diabled false;
  }                         
}
</script> 
y el codigo asi:

Código PHP:
<? foreach ($datos as $us
{
?>
<tr>  
    <td align="center"><?=$us['id'];?></td>
    <td align="center"><?=$us['n_matricula'];?></td>
    <td align="center"><?=$us['alumno_nom'];?> <?$us['alumno_nom'];?></td>
    <td align="center"><input name="sol1" type="text" size="1" disabled value="<?=$us['sol1'];?>"></td>
  <td align="center"><input name="sol2" type="text" size="1" disabled value="<?=$us['sol2'];?>"></td>
    <td align="center"><input name="ctrl1" type="text" size="1" disabled value="<?=$us['ctrl1'];?>"></td>
    <td align="center"><input name="ctrl2" type="text" size="1" disabled value="<?=$us['ctrl2'];?>"></td>
    <td align="center"><input name="ctrl3" type="text" size="1" disabled value="<?=$us['ctrl3'];?>"></td>
    <td align="center"><input name="ctrl4" type="text" size="1" disabled value="<?=$us['ctrl4'];?>"></td>
    <td align="center"><input name="examen" type="text" size="1" disabled value="<?=$us['examen'];?>"></td>
    <td align="center"><?=promedio($us['sol1'], $us['sol2'], $us['ctrl1'], $us['ctrl2'], $us['ctrl3'], $us['ctrl4'], $us['examen']);?></td>
  <td align="center"><input type="button" name="Editar" value="Editar" onclick="habilitar()"></td> 
</tr>
<? ?>
  #6 (permalink)  
Antiguo 24/06/2005, 08:34
Avatar de SiR.CARAJ0DIDA  
Fecha de Ingreso: junio-2004
Ubicación: Acá
Mensajes: 1.166
Antigüedad: 19 años, 10 meses
Puntos: 4
ahi dice DIABLED, es DISABLED

y tenes q habilitar los input type=text, no el buton..
  #7 (permalink)  
Antiguo 24/06/2005, 08:48
 
Fecha de Ingreso: octubre-2004
Ubicación: chile
Mensajes: 116
Antigüedad: 19 años, 6 meses
Puntos: 0
gracias hay funciono...aprovecho el post para una pregunta...
como hago para k ap presionar un input button redireccione a otra pag ???

esop grax
  #8 (permalink)  
Antiguo 24/06/2005, 10:36
Avatar de SiR.CARAJ0DIDA  
Fecha de Ingreso: junio-2004
Ubicación: Acá
Mensajes: 1.166
Antigüedad: 19 años, 10 meses
Puntos: 4
onclick="location.href='mi pagina'"
  #9 (permalink)  
Antiguo 24/06/2005, 10:42
 
Fecha de Ingreso: octubre-2004
Ubicación: chile
Mensajes: 116
Antigüedad: 19 años, 6 meses
Puntos: 0
gracias, tengo una variable en php ke kisiera mandar a la otra pag pero si pongo esto

<input type="button" value="Generar Excell" onclick="location.href='excell.php?valor='+$valor" >

me dice ke la variable no existe...como la mando???
  #10 (permalink)  
Antiguo 24/06/2005, 11:15
Avatar de JavierB
Colaborador
 
Fecha de Ingreso: febrero-2002
Ubicación: Madrid
Mensajes: 25.052
Antigüedad: 22 años, 2 meses
Puntos: 772
Hola dark_night

Sería preferible que pusieras un nuevo mensaje, para hacer una nueva pregunta, de esta forma quedaría todo más claro. De todas formas, prueba con esto:
Código PHP:
<input type="button" value="Generar Excell" onclick="location.href='excell.php?valor=<? echo $valor ?>'">
Saludos,
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 10:00.