Réponse acceptée !
Bonjour,
une solution : window.document.frm["n"+n]...
j'aurais plutôt mis le même nom
et utilisé : window.document.frm.nm[n]...
ou par ID ? : window.document.getElementById("nom"+n)...
<HTML>
<HEAD>
<TITLE></TITLE>
<script type="text/javascript">
function test()
{
for ( var n=1;n<=3;n++ )
alert("frm.n#="+window.document.frm["n"+n].value);
for ( n=0;n<window.document.frm.nm.length;n++ )
alert("frm.n[#]="+window.document.frm.nm[n].value);
n=1;
var tmp=window.document.getElementById("nom"+n);
while (tmp)
{ alert("ById="+tmp.value);
n++;
tmp=window.document.getElementById("nom"+n); }
}
</script>
</HEAD>
<BODY>
<form name="frm">
<!========================================>
<input type="text" name="n1" value="un">
<input type="text" name="n2" value="deux">
<input type="text" name="n3" value="trois"><br/>
<!========================================>
<input type="text" name="nm" id="nom1" value="un">
<input type="text" name="nm" id="nom2" value="deux">
<input type="text" name="nm" id="nom3" value="trois">
<!========================================>
<input type="button" value="test" onclick="test();">
</form>
</BODY>
</HTML>
Cordialement. Bul. ~Site~~Mail~