He puesto asi mis dos vetanas:
Ventana Padre:
Código HTML:
<html><head></head><body>
<form name="frm" id="frm">
<div id="bloque" style="float:left; width:80px; ">
<table width="80"><tr><td>
<input type=text
name="GtoFecha" id="GtoFecha"
value="">
</td></tr>
</table>
</div>
</form>
<a href="#" title="" onClick="window.open('003.html')" width="400" height="200">Gastos</a>
</body></html>
Ventana Hijo:
Código HTML:
<html>
<head>
<title></title>
</head>
<body>
<table width=2000> <tr><td width=110 height=50>
<table>
<tr><td class="td" align=right>Fecha:</td></tr>
</table></td><td>
<form id="myform" name="myform" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
<div id="bloque" style="float:left; width:80px; ">
<table width="80"><tr><td>
<input type=text class=input1
name="GtoFecha" id="GtoFecha"
value="">
</td></tr>
</table>
</div>
</form>
</td></tr></table>
<form><div style="clear:both; padding-top:15px"><button type="button" onClick="doIt()">Gasto Nuevo</button>
<br>
<br>
<input name="e" type="button" id="e" value="Enviar" onclick="document.getElementById('myform').submit()">
</div></form>
<script>
function doIt()
{
var f = document.getElementById('myform');
var b = document.getElementById('bloque');
var b2=b.cloneNode(true)
f.appendChild(b2);
var g = opener.document.getElementById('frm');
var h = opener.document.getElementById('bloque');
var g2=g.cloneNode(true)
h.appendChild(g2);
}
</script>
<?php
/*
if(isset($_POST) && !empty($_POST)){
echo '<pre>';
print_r($_POST);
echo '<pre>';
}
*/
?>
<a href="JavaScript:close();" title="pasar valor" onClick="regreso()">Regresar a la Ventana Principal</a>
<script>
function regreso()
{
var indice;
var ind;
indice=document.myform.GtoFecha.length;
for (ind = 0, ind<indice, ind++)
{
window.opener.document.frm.GtoFecha[ind].value =
window.document.myform.GtoFecha[ind].value;
}
}
</script>
</body>
</html>
Cuando me clona la primera vez lo hace bien, pero al clonar la segunda ocasion me duplica dos inputs y despues cuatro y asi sucesivamente.
Valroes no pasan de un formulario a otro
estoy trabajando con el bucle todavía.