Check the number of check boxes: function checkednum (ID)
{
VaR S;
S = 0;
For (I = 0; I <document. selectform. keyval. length; I ++)
{
If (document. selectform. keyval [I]. Checked)
{
S = S + 1;
}
}
If (S> 10)
{
Alert ("up to 10 ");
Id. Checked = false;
} Check whether at least one check box is selected: function ischecked (){
This. Disabled = true;
VaR check_id = Document. getelementsbyname ("keyval"); // or document. Form. inputname
VaR id = "";
For (I = 0; I <check_id.length; I ++ ){
If (check_id [I]. Checked ){
ID + = check_id [I]. value;
}
}
If (ID = ""){
Alert ("select at least one ");
Return false;
}
} Select all and reselect :// Code Note (lulu163.com): form1 is the form name, memberid is the check box, And selectbutton is the all-selected button.
Function selectall ()
{
For (VAR I = 0; I <document. form1.memberid. length; I ++ ){
VaR temp = Document. form1.memberid [I];
Temp. Checked =! Temp. checked;
}
If (document. form1.selectbutton. value = "select all ")
{
Document. form1.selectbutton. value = "cancel all selections ";
}
Else
{
Document. form1.selectbutton. value = "select all ";
}
} Check box (for example) <input name = "memberid" type = "checkbox" value = "check box value"> select all button: <input type = "button" name = selectbutton value = "select all" onclick = "selectall ()" style = "cursor: hand;"> none: function unselect ()
{
For (VAR I = 0; I <document. selectform. keyval. length; I ++ ){
VaR temp = Document. selectform. keyval [I];
Temp. Checked = false;
}
}