PDA

Ver la versión completa : Detectar change desde popup



AJaramillo
16-07-2012, 23:01
Buenas a tod@s,

Tengo el siguiente codigo




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script language="javascript" type="text/javascript" src="js/jquery.js"></script>
<script>
$().ready(function () {
$("#id").change( function () {
alert("LLEGO");
});
return false;
});

function buscar(nom) {
var llega = "hija.php?nom="+nom.value;
window.open(llega,"BUSCAR","fullscreen=no,status=no,dependent=yes, width=350, height=400,resizable=0,top=220,left=600");
}
</script>
</head>
<body>
<form id="depe" name="depe">
<td>Id: </td><td><input type="text" id="id" name="id" value="" /></td>
<br>
<td>Nombre: </td><td><input type="text" id="nombre" name="nombre" value="" onChange="buscar(this);" /></td>
</form<
</body>
</html>


hija.php



<?
$arr[0]["id"] = "1";
$arr[0]["nombre"] = "A1";
$arr[1]["id"] = "2";
$arr[1]["nombre"] = "A2";
$arr[2]["id"] = "3";
$arr[2]["nombre"] = "A3";

?>
<html>
<head>
<script language="javascript">
function enviar(a,b) {
opener.document.depe.id.value=a.value;
opener.document.depe.nombre.value=b.value;
window.close();
}
</script>
</head>
<body>
<form>
<table border="1">
<tr><th>Id</th><th>Nombre</th></tr>
<?php
$w=0;
for($j=0; $j<3; $j++) {
$h=$w+1;
echo "<td><input type='radio' name='x' onclick='enviar(this.form.c$w, this.form.c$h);'><input type='hidden' name='c$w' value='". $arr[$j]['id'] ."'>". $arr[$j]['id']."</td><td>";
echo "<input type='hidden' name='c$h' value='". $arr[$j]['nombre'] ."'>". $arr[$j]['nombre'];
$w = $w + 2;
echo "</TR>\n";
}
?>
</form>
</body>
</html>


La idea es la siguiente: Al escribir algo en el campo Nombre se abre la ventana popUp (hija.php) mostrando una lista tipo radioBotton y al seleccionar alguna opción se actualizan los campos en la ventana padre (padre.html) hasta aquí ta todo ok.

El lío es que al hacer la actualización de los campos en la ventana padre se registra el cambio en la caja Id debería ejecutar el código jquery que hay en $("#id").change( function () { .... mostrando el alert LLEGO, pero esto no sucede.

Qué debo hacer para que funcione de esa manera?

Gracias de antemano por su ayuda