Ver Mensaje Individual
  #10 (permalink)  
Antiguo 07/05/2012, 17:18
Avatar de Briss
Briss
 
Fecha de Ingreso: junio-2011
Mensajes: 1.293
Antigüedad: 12 años, 10 meses
Puntos: 12
Respuesta: Ocultar un textarea

Cita:
Iniciado por emprear Ver Mensaje
Amiga, creo que te estás complicando la vida, lo que te puso furoya cumple con los objetivos.
De todas maneras, visualmente creo que es un error ocultar los detalles en caso de que haya hecho click en "SI", suponiendo por supuesto, que si elije "NO", no sea necesario que justifique, creo que visualmente esto sería mejor

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <title>encuesta más detalles</title>
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6.  
  7. <style type="text/css">
  8. /*<![CDATA[*/
  9.  
  10. /* estilos */
  11. .oculta{
  12. display: none;
  13. }
  14. /*]]>*/
  15. <script type="text/javascript">
  16. //<![CDATA[
  17. function ocultar(ele){
  18. var tarea = document.getElementById('detalles_'+ele);
  19. tarea.style.display = 'none';
  20. tarea.value = '';
  21. }
  22. function mostrar(nele){
  23. var tarea = document.getElementById('detalles_'+nele);
  24. tarea.style.display = 'block';
  25. }
  26.  
  27. function verificar(){
  28. var d1= document.getElementById('detalles_p1').value;  
  29. var d2= document.getElementById('detalles_p2').value;      
  30. alert('Detalles pregunta 1:\n ' + d1 +'\nDetalles pregunta 2: \n' + d2 );
  31. }
  32. //]]>
  33. </head>
  34. <form action="#">
  35. <p>¿Está de acuerdo con la ley SOPA? --> <label for="p1">NO</label><input type="radio" value="no" id="p1" name="p1" onclick="ocultar(this.id)"/>
  36. <label for="p1_s">SI</label><input type="radio" value="si" id="p1_s" name="p1" onclick="mostrar(this.name);" /> <br />
  37. <textarea name="detalles_p1"  id="detalles_p1" rows="2" cols="40" class="oculta"></textarea>
  38. </p>
  39. <p>¿Cree que los juegos olímpicos van a tener éxito? --> <label for="p2">NO</label><input type="radio" value="no" id="p2" name="p2" onclick="ocultar(this.id)"/>
  40. <label for="p2_s">SI</label><input type="radio" value="si" id="p2_s" name="p2" onclick="mostrar(this.name);" /> <br />
  41. <textarea name="detalles_p2"  id="detalles_p2" rows="2" cols="40" class="oculta"></textarea>
  42. </p>
  43. <p>
  44. <input type="button" value="procesar encuesta" name="procesar" onclick="verificar();"/>
  45. </p>
  46. </form>
  47. </body>
  48. </html>

Si se agregan preguntas, basta utilizar 3, 4, 5 etc como substitución en los id y names de los elementos

Saludos

Gracias por la ayuda