![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
03/09/2008, 00:23
|
![Avatar de KarlanKas](http://static.forosdelweb.com/customavatars/avatar11549_2.gif) | Moderador extraterrestre | | Fecha de Ingreso: diciembre-2001 Ubicación: Madrid
Mensajes: 6.987
Antigüedad: 23 años, 1 mes Puntos: 61 | |
Respuesta: habilitar un texto segun radiobubtton Puedes probar así: Código PHP: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<script>
function inicio(){
inputs=document.getElementsByTagName("INPUT");
for(a=0;a<inputs.length;a++){
if(inputs[a].type=="radio"){
inputs[a].setAttribute("onclick", 'habilitar(this)');
inputs[a].onclick=function(){habilitar(this)};
}
}
}
function habilitar(esto){
nombre=esto.name.split("_")[0];
deshabilitado=(esto.value==0);
for(a=0;a<inputs.length;a++){
if(inputs[a].type=="text" && inputs[a].name.indexOf(nombre)!=-1){
inputs[a].disabled=deshabilitado;
}
}
}
window.onload=inicio;
</script>
</head>
<body>
<form action="#">
<input name="p6_1" type="radio" value="1" />
<input name="p6_1" type="radio" value="0" />
<input name="p6_2" type="text" class="forms" size="20">
<input name="p6_3" type="text" class="forms" size="20">
<input name="p6_4" type="text" class="forms" size="20">
<br />
<br />
<input name="p5_1" type="radio" value="1" />
<input name="p5_1" type="radio" value="0" />
<input name="p5_2" type="text" class="forms" size="20">
<input name="p5_3" type="text" class="forms" size="20">
<input name="p5_4" type="text" class="forms" size="20">
<br />
<br />
<input name="p4_1" type="radio" value="1" />
<input name="p4_1" type="radio" value="0" />
<input name="p4_2" type="text" class="forms" size="20">
<input name="p4_3" type="text" class="forms" size="20">
<input name="p4_4" type="text" class="forms" size="20">
</form>
</body>
</html>
Aquí lo importante es poner el script del principio y ya está. Siempre y cuando respetes la lógica de los name de los inputs. No tienes que añadir ningún onclick ni nada. Sólo añadir el script al principio de la página y ya está.
Espero que te sirva!
__________________ Cómo escribir
No hay pregunta tonta, sino tonto que quiere seguir en la ignorancia. |