Tema: formulario
Ver Mensaje Individual
  #6 (permalink)  
Antiguo 16/04/2009, 19:43
Avatar de Triby
Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: formulario

Creas un div con estilo display:none; y un javascript que lo muestre:

Código javascript:
Ver original
  1. function mostrar_ocultar( divToHide ) {
  2.     var elem, vis;
  3.     if( document.getElementById ) // this is the way the standards work
  4.         elem = document.getElementById( divToHide );
  5.     else if( document.all ) // this is the way old msie versions work
  6.         elem = document.all[divToHide];
  7.     else if( document.layers ) // this is the way nn4 works
  8.         elem = document.layers[divToHide];
  9.     vis = elem.style;
  10.         // Ocultar o mostrar, dependiendo el estado actual
  11.     if(vis.display == 'block') {
  12.         vis.display = 'none';
  13.     } else {
  14.         vis.display = 'block';
  15.     }
  16. }

Código html:
Ver original
  1. <div id="enlace-mostrar" style="display:block;"><a href="#formulario" onclick="mostrar_ocultar('formulario'); mostrar_ocultar('enlace-mostrar');">Mostrar formulario</a></div>
  2. <div id="formulario" style="display:none;"><form method="post">
  3. Aqui los campos del formulario.
  4. </form>
  5. <a href="#enalce-mostrar" onclick="mostrar_ocultar('formulario'); mostrar_ocultar('enlace-mostrar');">Ocultar formulario</a>
  6. </div>

Notas: Al hacer click en "Mostrar formulario" oculta el enlace y muestra el formulario, "Ocultar formulario" restablece el estado original de ambos bloques.
__________________
- León, Guanajuato
- GV-Foto