i checkbox selezione[] e gli input quantita[] e totale[] corrispondenti sono allo stesso livello?
Intendo dire, se prendo un array con tutti i checkbox, uno con tutte le quantità ed uno con tutti i totali, l'elemento in posizione 3 del primo array corrisponde all'elemento in posizione 3 degli altri due?
Se si, ti basta:
metti che questa sia la tua form
<form onsubmit="return checkQuantity()" action...
Codice PHP:
function checkQuantity(){
var checks = document.getElementsByName('selezione[]');
var quantita = document.getElementsByName('quantita[]');
var totale = document.getElementsByName('totale[]');
var ret = true;
for(i = 0; i < checks.length; i++){
if(checks[i].checked)
{
if(parseInt(quantita[i].value) > parseInt(totale[i].value)){
alert("La quantita' scelta nel campo numero "+(i + 1)+" e' maggiore della quantita' in magazzino");
ret = false;
break;
}
}
}
return ret;
}