Please Log In to save to favorites
TAGs
checkbox, checked, count, javascript


Versions
Count number of checked checkboxes
Count the number of checked checkboxes in a form.
      
    1.   function doCount(f) {
    2.    var j = 0;
    3.    for ( i = 0 ; i < f.length; i++ ) {
    4.    if ( ( f[i].type == "checkbox" ) && ( f[i].checked ) ) {
    5.    j++;
    6.    }
    7.    }
    8.    return j;
    9.   }
    10.   
    11.   doCount(document.forms.formName);
Comments


Awesome

Posted by: steven around 18 Months Ago

This is exactly what I needed!