salve
a scuola il professore di informatica ci ha fatto scrivere l'esercizio riportato sotto per ricercare il valore massimo in un vettore,ma provandolo a casa non corrisponde al risultato richiesto.ho parlato con il professore e mi ha detto che l'esercizio è giusto così e non ha voluto provarlo insieme. quest'anno devo affrontare la maturità ed, avendo informatica esterna, vorrei avere dei chiarimenti da voi in modo da non fare brutte figure all'esame. molto probabilmente è un errore banale ma da sola non lo sono riuscita ad individuare.
aspetto un vostro aiuto
<html>
<head> <title>ricerca di elementi </title>
<script>
function aggiungiInput()
{ var dimensione=document.forms["strumenti"]["txtquanti"].value;
for (n=0; n<dimensione; n=n+1)
{
testo="numero "+n;
var formNumeri=document.getElementById("numeri");
var elementoP=document.createElement("P");
var elementoT=document.createTextNode(testo);
var elementoI=document.createElement("INPUT");
formNumeri.appendChild(elementoP);
elementoP.appendChild(elementoT);
elementoP.appendChild(elementoI);
elementoI.type="text";
elementoI.name="txtnumero"+n;
}
}
function ricerca()
{
var numero= new Array();
var dimensione=document.forms["strumenti"]["txtquanti"].value;
max=0;
for (n=0; n<dimensione; n=n+1)
{
if (numero[n]>max)
{ max=numero[n]};
}
}
document.write("<p>valore massimo "+max"</p>");
}
</script>
</head>
<body>
<form id="strumenti" >
Inserire <input type="text" name="txtquanti"> elementi di input
<input type="button" value="aggiungi" onClick="aggiungiInput()">
</form>
<form id="numeri" >
<input type="button" value="ricerca" onClick="ricerca()">
</form>
</body>
</html>