così funzia...macchinoso sicuramente...conosco na cippa di jscodice:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> <script language="JavaScript" type="text/javascript"> <!-- var c; function maxArray(anArray) { maxi = ''; for (i=0;i<anArray.length;i++) { if (anArray[i] > maxi) { maxi = anArray[i]; //------------------modifiche----------------------------- c = i; //memorizzo la posizione del valore maggiore (nonchè il numero del campo, nel mio caso è uguale al nome del campo) //------------------modifiche----------------------------- } // if (anArray[i] > maxi) } // for (i=0;i<anArray.length;i++) return maxi; } // function maxArray(anArray) //--> <!-- var myArr = new Array(); function assegnaArray(aForm) { a = 0; var tmpArr = new Array(); nbFigli = aForm.children.length; for (i=0;i<nbFigli;i++) { curFiglio = aForm.children(i); if (curFiglio.tagName == 'INPUT' && curFiglio.type == 'text') { tmpArr[a++] = parseFloat(curFiglio.value); } // if (curFiglio.tagName == 'INPUT' && curFiglio.type == 'text') } // for (i=0;i<nbFigli;i++) return tmpArr; } // function assegnaArray(aForm) function ass() { myArr = assegnaArray(document.getElementById('myform')); alert(myArr); alert(maxArray(myArr)); //------------------modifiche--------------------------- alert("il campo con il value max è "+c); //il numero(nel mio caso anche il nome) del campo fff.ppp.value = maxi; //maxi contiene il numero maggiore document.fff.elements[c].value = maxi+1; //------------------modifiche--------------------------- } // function ass() //--> </script> </head> <body> <form name="fff" action="" method="post" id="myform"> A<input name="0" type="text" id="c[0]" size="20"> B<input name="1" type="text" id="c[1]" size="20"> C<input name="2" type="text" id="c[2]" size="20"> D<input name="3" type="text" id="c[3]" size="20"> E<input name="4" type="text" id="c[4]" size="20"> //------------------modifiche--------------------------- <input type="text" name="ppp" size="20"> //------------------modifiche--------------------------- </p> </form> <input type="button" value="Assegna" onclick="ass()"> </body> </html>![]()