Code:
function countCheckBoxes(){
var checkboxes = document.getElementsByTagName("INPUT");
var total = 0
for(i=0;i<checkboxes.length;i++){
if(checkboxes[i].checked) total ++;
}
alert(total);
}
This should work, might behave funny if there's more than one form with checkboxes or radio buttons in the page, but that can always be fixed.