Select All or invert settings for the checkbox in the list, and select all for the checkbox

Source: Internet
Author: User

Select All or invert settings for the checkbox in the list, and select all for the checkbox
Select all settings for checkbox selection in the list

1 

The above code mainly handles

1. If a row is selected in the list, the checkbox of the row is selected. If you click it again, the checkbox is deselected.

2. The list contains all selected checkboxes.

 

 

 

 

The following is a piece of code I have added:

 1 ... 2 <input id="allid"  type="checkbox" onclick="selectAll()"/> 3  4 <s:iterator value="page.records"> 5 <td style="CURSOR: hand; HEIGHT: 30px" align="center" width="2%"> 6                     <input class="select" type="checkbox" name="selectList" value="${id}"/> 7                 </td> 8 ... 9 10 11 function selectAll() {12             var allche = document.getElementById("allid");  13             var che = document.getElementsByName("selectList");  14             if(allche.checked == true){  15                 for(var i=0;i<che.length;i++){  16                     if(che[i].checked==true){17                         che[i].checked=false;18                     }19                     else{20                         che[i].checked="checked";21                     }22                 }  23             }else{  24                 for(var i=0;i<che.length;i++){  25                     if(che[i].checked==true){26                         che[i].checked=false;  27                     }28                     else29                     {30                         che[i].checked="checked";31                     }32                     33                 }  34             } 35         }

 

Related Article

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.