HTML code:
<TableID= "Purchase-info"class= "Table table-bordered table-hover table-striped"cellspacing= "0"width= "100%"Align= "Center"> <caption>Purchase List</caption> <thead> <TR> <TD><inputclass= "Allchoose"type= "checkbox"onclick= "SelectAll ()"></TD> <th>Item number</th> <th>Item Name</th> <th>Item classification</th> <th>Specification model</th> <th>Suppliers</th> <th>Purchasing Staff</th> <th>Purchase Quantity</th> <th>Note</th> <th>Inbound operations</th> </TR> </thead> <tbodyID= "Purchase-item"> <TR> <TD><inputclass= "Choose"type= "checkbox"/></TD> <TD>001</TD> <TD>Real color water-based pen</TD> <TD>Stationery</TD> <th>Box (12 Branch)</th> <th>Shanghai True Color Stationery Store</th> <th>Xiao Wang</th> <th>50</th> <th>No notes</th> <TD><ButtonID= "Instorage">Storage</Button></TD> </TR> <TR> <TD><inputclass= "Choose"type= "checkbox"/></TD> <TD>001</TD> <TD>Real color water-based pen</TD> <TD>Stationery</TD> <th>Box (12 Branch)</th> <th>Shanghai True Color Stationery Store</th> <th>Xiao Wang</th> <th>50</th> <th>No notes</th> <TD><ButtonID= "Instorage">Storage</Button></TD> </TR> </tbody></Table>
JavaScript Code:
//Select all function functionfunctionSelectAll () {varAllchoose=document.getelementsbyclassname ("Allchoose") [0]; varList=document.getelementsbyclassname ("Choose"); if(allchoose.checked) { for(varI= 0;i<list.length;i++) {list[i].checked=true; } return true; }Else{ for(vari=0;i<list.length;i++) {list[i].checked=false; } return false; }}
The effect is as follows:
Implementation of JavaScript full-selection function