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