Occorre verificare se l'elemento e` una matrice o un singolo:
if(!chek.length)
Ad esempio:codice:function deleteNews() { var chek = document.news.elements['notizia[]']; var cheks = 0; if(!chek.length) { checks = check.checked } else { for (var i=0; i<chek.length; i++) { if(chek[i].checked) cheks++ } } if (cheks == 0) { alert("Non hai selezionato alcuna notizia"); return false; } else { var asd = confirm('Sicuro che vuoi eliminare le notizie selezionate?'); if (asd) { document.news.action="?ID=news;pID=delete"; document.news.submit(); return true; } else { return false; } } }

Rispondi quotando