|
|
Joined: Dec 1999
Posts: 30,867
Master Elite Member
|
function Checkboxes_CountState(FormName, State) {
/*
Purpose
Used to count the number of checkboxes within a specified form
that are set to a specified state (true or false).
Parameters
FormName (string) = Only checkboxes within this form are counted.
State (optional boolean) = To count the number of checked checkboxes,
set this to true. To count unchecked checkboxes, set to false.
Default: true
Return (integer)
Return the total number of checkboxes that are set to the same state as
indicated by State.
Version History
1.00 2009.6.25 Tested by Russ Tanner on IE6/FF3.
*/
// Default State to true.
if (typeof State == 'undefined') State = true;
var frm = document.forms[FormName];
var c = frm.elements.length;
var r = 0;
for(var i=0; i<c; i++) {
if (frm.elements[i].type == 'checkbox') r += (frm.elements[i].checked == State) ? 1 : 0;
}
return r;
}
|
|
|
|
Entire Thread
|
Checkboxes_CountState() - How Many Checkboxes are Checked or Unchecked?
|
Russ
|
06/26/09 08:30 AM
|
|
|
|