CheckBox do all selected, cancel all effects

Source: Internet
Author: User

The use of bulk check and cancel multiple checkboxes is simple, and this feature is also very common. Here's a summary.

The notation in HTML:

1 <DivID= "Ftpfiledowntr">2     <Buttononclick= "getbatchvalues ();"value= "Get the value of bulk selection"/>3 </Div>4 <Table>5         <TRID= "Ftpfiletitle">6             <th>7                 <inputtype= "checkbox"onclick= "Checkall (this.checked)"/>Select All/Cancel all8             </th>9             <th>File name</th>Ten             <th>File size</th> One             <th>File Progress</th> A             <th>File status</th> -             <th>Operation</th> -         </TR> the         <TR> -             <TD> -                 <inputtype= "checkbox"name= "Checkone"value= "a"/> -             </TD> +             <TD>File name A</TD> -             <TD>100M</TD> +             <TD>10%</TD> A             <TD>Status 1</TD> at             <TD>Action 1</TD> -         </TR> -         <TR> -             <TD> -                 <inputtype= "checkbox"name= "Checkone"value= "B"/> -             </TD> in             <TD>File name b</TD> -             <TD>100M</TD> to             <TD>10%</TD> +             <TD>Status 2</TD> -             <TD>Action 2</TD> the         </TR> *         <TR> $             <TD>Panax Notoginseng                 <inputtype= "checkbox"name= "Checkone"value= "a"/> -             </TD> the             <TD>File name C</TD> +             <TD>100M</TD> A             <TD>10%</TD> the             <TD>Status 3</TD> +             <TD>Action 3</TD> -         </TR> $ </Table>
View Code

CheckBox batch selection, batch cancellation effect of JS notation:

1 function Checkall (checked) {// Bulk Select, bulk cancel 2     $ (' input[name= ') Checkone "]). attr (" Checked ", checked); 3 }
View Code

To get the value of a batch-checked checkbox:

1 functiongetbatchvalues (CTX) {2     varcheckedarr=$ ("Input[name= ' Checkone ']:checked");3     if(Checkedarr.length = = 0){4Alert ("Select at least one piece of data");5         return false;6     }7     varValuestr= "";//value with "," as delimiter8      for(vari=0;i<checkedarr.length;i++){9         if(i==0){Tenvaluestr+=$ (Checkedarr[i]). Val (); One}Else{ Avaluestr+= "," +$ (Checkedarr[i]). Val (); -         } -     } the alert (VALUESTR);  -}
View Code

That's it.

CheckBox do all selected, cancel all effects

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.