Lascia perdere il for
Seguirei un' altra strada: bisogna passare alla pop-up quella n che accompagna "c" e "d" negli ID delle SELECT e degli INPUT aggiunti.
Ma cosa fa quel bottone che "ne aggiunge"? Apre dei display: none; o li crea dinamicamente?
Io, nell' ipotesi di una dinamica, ho buttato giù questo modellino (poi chiaramente ti liberi degli alert):
codice:
<html>
<head><title>Dynamic IDs</title>
<script type="text/javascript">
function launch(x){
alert("paramentro passato alla funzione: \tx = " + x);
frm=window.open('', '', 'width=480');
frm.document.open();
frm.document.writeln('<html><body><form>
');
frm.document.writeln('<input name="f' + x + '" value="" type="text">');
frm.document.writeln('<input value="Send" type="button" onClick=\\'alert("ok anche nella pop-up \tx = ' + x + '"); '+
'window.opener.document.getElementById("d' + x + '").value=f' + x + '.value; '+
'window.close();\\'>');
frm.document.writeln('</form></body></html>');
frm.document.close()
}
</script>
</head>
<body bgcolor="#900000" text="#E3E3E3">
<div align="center">
<table width="520"><tr>
<td>
<script type="text/javascript">
var n = 7;
document.write(
'\n<select id="c' + n + '" onChange=\\'launch(n);\\'> '+
'\n <option>Tina '+
'\n <option>Enzo '+
'\n <option>Paola '+
'\n</select> '+
'\n<input id="d' + n + '" value="" type="text"> '
);
</script>
<hr>
</td></tr>
</table>
</div>
</body>
</html>
Se cambi Valore alla var n = 7; nell' ipotesi di una nuova e diversa SELECT, vedi che anche la pop-up lo viene messa al corrente di n .