Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/01/2012, 11:30
Avatar de ananda
ananda
 
Fecha de Ingreso: enero-2012
Mensajes: 345
Antigüedad: 12 años, 4 meses
Puntos: 14
mostrar/ocultar inputs segun boton

Hola amigos, me acabo de registrar en el foro porqué he visto que normalmente la gente es muy amable con los nuevos en la programación.
esta es mi duda : Yo quería hacer un formulario en que salieran unos botones y tu le dieses por ejemplo al botón : nombre y te apareciera el input para poner el nombre.
He tratado de hacerlo, asignandóle unos valores a un input hidden según que botón pulsas (nombre, correo o informacion adicional). Pero no me funciona, alguien sabria decirme cual es el problema? Aqui dejo mi código completo :
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Vipefy invisible </title>
<head>
<script type="text/javascript">



function mostrarcampos(){
if (document.perfil.hidden.value = showname){
document.getElementById('nameformdiv').style.display='block';
}else if{
document.perfil.hidden.value = showmail){
document.getElementById('mailformdiv').style.display='block';
}else if{
document.perfil.hidden.value = showadicional){
document.getElementById('opcionalformdiv').style.display='block';
}
}
}
}

</script>
<style>	  

	  </style>
	  </head>


	 



<body>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post" name="perfil" onload=>
<input type="button" value="Nombre" id="nombre" onclick="document.perfil.hidden.value=showname" /><br>
<input type="button" value="Correo electronico" id="mail" onclick="document.perfil.hidden.value=showmail" /><br>
<input type="button" value="Informacion adicional" id="opcional" onclick="document.perfil.hidden.value=showadicional" />
<input type="hidden" value="" name="hidden" id="hidden" />

</form>

<div id="nameformdiv" style="display.none;">
<p>Nombre </p>
<p><input type="text" id="nameformdiv.name" class="input" /></p>
<p>Apellidos </p>
<p><input type="text" id="nameformdiv.surname" class="input" /></p>
</div>


<div id="mailformdiv" style="display.none;">
<p>Correo Electronico</p>
<p><input type="text" id="mailformdiv.correo" class="input" /></p>
</div>


<div id="opcionalformdiv" style="display.none;">
<p>Ciudad de residencia</p>
<p><input type="text" id="opcionalformdiv.ciudad" class="input" /></p>
</div>

</body>
</html>
Si me pudieráis ayudar, os estaria realmente agradecido!