Ver Mensaje Individual
  #4 (permalink)  
Antiguo 06/10/2012, 10:23
Avatar de NSD
NSD
Colaborador
 
Fecha de Ingreso: mayo-2012
Ubicación: Somewhere
Mensajes: 1.332
Antigüedad: 12 años, 9 meses
Puntos: 320
Respuesta: Enviar datos de un iframe via POST

Cita:
hacéis cosas muy extrañas.
valla que si

me gusto el desafio yo tampoco lo hise nunca pero aqui esta:

Index.html/php:
Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3.     <head>
  4.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5.     <title>Inicio</title>
  6.     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
  7.     <Script Type="text/javascript">
  8.         function AgregarCampos(ID,VAL){
  9.             campo = '<input type="hidden" id="'+ID+'"  name="'+ID+'"  value="'+VAL+'" />';
  10.             $('#formulario').append(campo);
  11.         }
  12.         function CargarCamposIframe(){
  13.             $(".Indirecto",datos.document).each(function(){        
  14.                 AgregarCampos($(this).attr('id'), $(this).val());
  15.             });
  16.             $('#formulario').submit();//Esta linea envia el formulario
  17.         }          
  18.     </Script>
  19.     </head>
  20.  
  21.     <body>
  22.         <form action="Recepcion.php" method="post" id="formulario">
  23.  
  24.         Nombre:
  25.         <input type="text" name="txt_Nombre" />
  26.         <iframe src="Frame.html" width="500" height="300" name="datos" id="datos" ></iframe>
  27.        
  28.         </form>
  29.  
  30.         <button name="btn_Ingresar" onclick="CargarCamposIframe();">Enviar</button>
  31.     </body>
  32. </html>

Frame.html/php:

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3.     <head>
  4.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5.         <title>Frame</title>
  6.     </head>
  7.  
  8.     <body>
  9.         Direccion
  10.         <input type="text" name="txt_Direccion" id="txt_Direccion" Class="Indirecto" value="hola"/>
  11.     </body>
  12. </html>

con ese codigo, todos los elementos de la clase Indirecto dentro del iframe se comportaran como si estubiesen en la misma pagina que el formulario al hacer click en el boton.

saludos.
__________________
Maratón de desafíos PHP Junio - Agosto 2015 en FDW | Reglamento - Desafios