anche il mio codice, anche se funzionante, era scazzato (l'ho fatto troppo in velocità). Decisamente troppi cicli...
Siccome non mi riesce di editare il messaggio, ecco qui la funzione modificata:
codice:function checkCount() { var limit = 3; for (var f=0; f<6; f++) { var checkBox = document.getElementById('vetrina'+f); checkBox.onclick = function() { var checkedCount = 0; for (var j=0; j<6; j++) { checkedCount += (document.getElementById('vetrina'+j).checked)? 1 : 0; if (checkedCount>limit) { alert("Hai superato il limite di " + limit + " checkbox selezionate.") this.checked = false; break; } } } } }

). Decisamente troppi cicli...
Rispondi quotando