Foros del Web » Programando para Internet » Javascript »

[SOLUCIONADO] problema al enviar datos del popud a pagina padre

Estas en el tema de problema al enviar datos del popud a pagina padre en el foro de Javascript en Foros del Web. Buenas. Tengo un php donde tengo un campo que es llenado por medio de un popup, en otro php tengo el popup que es un ...
  #1 (permalink)  
Antiguo 09/03/2013, 23:32
 
Fecha de Ingreso: abril-2011
Mensajes: 8
Antigüedad: 13 años
Puntos: 0
Pregunta problema al enviar datos del popud a pagina padre

Buenas.
Tengo un php donde tengo un campo que es llenado por medio de un popup, en otro php tengo el popup que es un formulario con unos campos para llenar.
El problema que tengo es que al hacer clic en el botón para enviar los datos del popup, no pasa nada, pero si le doy de nuevo clic al botón hay si envía los datos, en pocas palabras tengo que darle mas de una vez para que envié la información.

les dejo en codigo de los 2 archivos.
datos.php
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Datos</title>
<script>
var mipopup;
function popup(){
mipopup= window.open("POPUP.PHP","PRUEBA","width=700, height=180,menubar=si");
mipopup.focus();
}
</script>
</head>

<body>
<form id="neo" name="neo" method="post" action="">
<table width="200" border="1">
<tr>
<td>NOMBRE</td>
<td><input type="text" name="nom" id="nom" /></td>
</tr>
</table>
<p>
<input type="submit" name="Submit" value="Enviar" onclick="popup()" />
</p>
</form>
</body>
</html>

Archivo popup

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<script>
function datos(nom){
opener.document.neo.nom.value=nom;
//window.close();
}
</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<table width="200" border="1">
<tr>
<td>NOMBRE</td>
<td><input type="text" name="nom" id="nom" value="<?php echo $nom;?>" /></td>
</tr>
<tr>
<td>APELLIDO</td>
<td><!--<input type="text" name="textfield2" />--></td>
</tr>
<tr>
<td>TELEFONO</td>
<td><!--<input type="text" name="textfield3" />--></td>
</tr>
</table>

<p>
<input type="submit" name="S" id="S" value="Enviar" onclick="<?php echo " javascript:datos('".$nom."')";?>" />
</p>
</form>
<p></p>
</body>
</html>

lo estaba intentando hacer solo con el primer dato que es el nombre, pero no me sale. Como decía anteriormente me toca hacer varias veces clic en el botón.
cuando ejecuto el popup y miro el codigo fuente cuando eje cuto me sale en el onclick de boton esto onclick=" javascript:datos('')" si lla tiene valor el input nom.
Les agradezco la colaboración.
  #2 (permalink)  
Antiguo 09/03/2013, 23:56
Avatar de emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 9 meses
Puntos: 1567
Respuesta: problema al enviar datos del popud a pagina padre

haciendo esto funciona
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=iso-8859-1" />
  5.  <title>Datos</title>
  6.  <script>
  7.  var mipopup;
  8.  function popup(){
  9.  mipopup= window.open("popup.html","PRUEBA","width=700, height=180,menubar=si");
  10.  mipopup.focus();
  11.  }
  12.  </script>
  13.  </head>
  14.  
  15.  <form id="neo" name="neo" method="post" action="#">
  16.  <table width="200" border="1">
  17.  <tr>
  18.  <td>NOMBRE</td>
  19.  <td><input type="text" name="nom" id="nom" /></td>
  20.  </tr>
  21.  </table>
  22.  <p>
  23.  <input type="button" name="Submit" value="Enviar" onclick="popup()" />
  24.  </p>
  25.  </form>
  26.  </body>
  27.  </html>

popup.html

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=iso-8859-1" />
  5.  <title>Documento sin t&iacute;tulo</title>
  6.  <script>
  7.  function datos(nom){
  8.  opener.document.neo.nom.value=nom;
  9.  //window.close();
  10.  }
  11.  </script>
  12.  </head>
  13.  
  14.  <form id="form1" name="form1" method="post" action="#">
  15.  <table width="200" border="1">
  16.  <tr>
  17.  <td>NOMBRE</td>
  18.  <td><input type="text" name="nom" id="nom" value="carlos" /></td>
  19.  </tr>
  20.  <tr>
  21.  <td>APELLIDO</td>
  22.  <td><!--<input type="text" name="textfield2" />--></td>
  23.  </tr>
  24.  <tr>
  25.  <td>TELEFONO</td>
  26.  <td><!--<input type="text" name="textfield3" />--></td>
  27.  </tr>
  28.  </table>
  29.  
  30. <p>
  31.  <input type="button" name="S" id="S" value="Enviar" onclick="datos('carlos');" />
  32.  </p>
  33.  </form>
  34.  <p></p>
  35. </body>
  36.  </html>
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.
  #3 (permalink)  
Antiguo 10/03/2013, 00:16
 
Fecha de Ingreso: abril-2011
Mensajes: 8
Antigüedad: 13 años
Puntos: 0
Respuesta: problema al enviar datos del popud a pagina padre

HOLA emprear.
Si yo se que asi funciona, para datos estáticos, pero lo que necesito es que funcione con cualquier valor que se digite en la caja de texto nom.
  #4 (permalink)  
Antiguo 10/03/2013, 00:28
 
Fecha de Ingreso: abril-2011
Mensajes: 8
Antigüedad: 13 años
Puntos: 0
Respuesta: problema al enviar datos del popud a pagina padre

Hola a todos,
Ya lo solucione y me funciono.
la función datos quedaría asi.

<script>
function datos(nom){
opener.document.neo.nom.value=document.form1.nom.v alue;
window.close();
}
</script>

en conclusion seria

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<script>
function datos(nom){
opener.document.neo.nom.value=document.form1.nom.v alue;
//window.close();
}
</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="#">
<table width="200" border="1">
<tr>
<td>NOMBRE</td>
<td><input type="text" name="nom" id="nom" value="" /></td>
</tr>
<tr>
<td>APELLIDO</td>
<td><!--<input type="text" name="textfield2" />--></td>
</tr>
<tr>
<td>TELEFONO</td>
<td><!--<input type="text" name="textfield3" />--></td>
</tr>
</table>

<p>
<input type="button" name="S" id="S" value="Enviar" onclick="datos('');" />
</p>
</form>
<p></p>
</body>
</html>

Etiquetas: campos, formulario, html, input, padre, php
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:28.