Ho creato una funzione per controllare se in un gruppo di menu select vengono ripetute selezioni con lo stesso valore, però succede sempre che l'ultima select non risponde mai!
"nVar" corrisponde al numero identificativo di quel menu select, -1 perchè di base indico sempre il successivo.
Codice:
for(i=0;i<totComponenti;i++){
if((document.getElementById("compvar_"+Math.round(nVar-1)).value == document.getElementById("compvar_"+i).value)&&(document.getElementById("compvar_"+Math.round(nVar-1)).value != '#')&&((Math.round(nVar-1) != i)&&(Math.round(nVar-1)<totComponenti))){
altriVal = true;
document.getElementById("compvar_"+Math.round(nVar-1)).value = '#';
document.getElementById("nComp_"+Math.round(nVar-1)).disabled = true;
document.getElementById("compDesc_"+Math.round(nVar-1)).disabled = true;
document.getElementById("compDesc_"+Math.round(nVar-1)).value = '';
break
}else{
altriVal = false;
}
alert(Math.round(nVar-1) + " - " + i);
}