Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/04/2014, 15:48
idelatorre
 
Fecha de Ingreso: febrero-2003
Mensajes: 37
Antigüedad: 21 años, 3 meses
Puntos: 0
Pregunta radio button y divs

hola! Quisiera saber si me pueden ayudar con este form... Luego de muchos (muchísimos) intentos y pruebas logre que funcione a medias este formulario, lo que necesito es que al clickear sobre un radio button se muestro la div correspondiente, lo logre con 1, pero con 2 no hay forma... Asi mismo con hasta 6.... aca el código! Help me!!!

Saludos y gracias por lo que puedan hacer

<!doctype html>
<html>
<head>
<meta charset="windows-1250">
<title>Untitled Document</title>

<script>
<!--

function cantidad_hijos(elemento) {

if(elemento.value=="0") {
document.getElementById("hijos1").style.display = "none";
} else {
document.getElementById("hijos1").style.display = "block";
}
}

-->
</script>

</head>

<body>

<form>

<p>
<label for="hijos">Hijos</label>
<input name="hijos" id="hijos"type="radio" value="0" checked="checked" onclick="cantidad_hijos(this)" />0
<input name="hijos" id="hijos" type="radio" value="1" onclick="cantidad_hijos(this)" />1
<input name="hijos" id="hijos" type="radio" value="2" onclick="cantidad_hijos(this)" />2
<br />
</p>

<div id="hijos1" style="display:none">
<label for="nombre">Nombre: </label> <input name="nombre" type="text" id="nombre" /><br />
<label for="edad">Edad: </label> <input name="edad" type="text" id="edad" /><br />
<label for="dni">DNI: </label> <input name="dni" type="text" id="dni" /><br />
</div>

<div id="hijos2" style="display:none">
<label for="nombre">Nombre: </label> <input name="nombre" type="text" id="nombre" /><br />
<label for="edad">Edad: </label> <input name="edad" type="text" id="edad" /><br />
<label for="dni">DNI: </label> <input name="dni" type="text" id="dni" /><br /><br />
------------------<br /><br />
<label for="nombre2">Nombre: </label> <input name="nombre2" type="text" id="nombre2" /><br />
<label for="edad2">Edad: </label> <input name="edad2" type="text" id="edad2" /><br />
<label for="dni2">DNI: </label> <input name="dni2" type="text" id="dni2" /><br />

</div>

</form>

</body>
</html>