Personal Summary 1 [check the number of check boxes selected:]

Source: Internet
Author: User
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;
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.