If the currently selected quantity is not selected and the Full selection box is selected, the status of the marquee is changed to no selection
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<title>javascript Full selection (total elimination), dynamic selection total elimination </TITLE>
<script type= "Text/javascript" language= "JavaScript" >
function Checkall ()//This method is used to select all and eliminate check boxes
{
var items=document.getelementsbyname ("Checkc");
var Itemall=document.getelementbyid ("All");
for (Var i=0;i<items.length;i++) {
items.checked=itemall.checked;
}
}
function Resall () {
var items=document.getelementsbyname ("Checkc");
var Itemall=document.getelementbyid ("All");
var ite=0; This variable is used to record the number of currently selected checkbox
for (Var i=0;i<items.length;i++) {
Get the number of currently selected checkbox
if (items.checked) {
ite++;
}
}
If the currently selected quantity is not selected, and the Full selection box is selected
The status of the marquee is changed to no selection
if (ite==items.length-1&&itemall.checked) {
Itemall.checked=false;
}
/*---
This applies to you want to remove the option to remove the full selection effect
if (ite==0&&itemall.checked) {
Itemall.checked=false;
}
---*/
If the currently selected quantity is zero and the full selection box is unchecked
Changes the status of the marquee to a selection
if (ite==items.length&&!itemall.checked) {
Itemall.checked=true;
}
}
</script>
</HEAD>
<BODY>
This script is suitable for use when the database is dynamically created, because there is no need to pass parameters inside. So scalability is not very high <br/>
<input type= "checkbox" Name= "All" id= "All" onclick= "Checkall ()" > select All
<input type= "checkbox" Name= "CHECKC" onclick= "Resall ()" >1
<input type= "checkbox" Name= "CHECKC" onclick= "Resall ()" >2
<input type= "checkbox" Name= "CHECKC" onclick= "Resall ()" >3
<input type= "checkbox" Name= "CHECKC" onclick= "Resall ()" >4
<input type= "checkbox" Name= "CHECKC" onclick= "Resall ()" >5
<input type= "checkbox" Name= "CHECKC" onclick= "Resall ()" >6
<input type= "checkbox" Name= "CHECKC" onclick= "Resall ()" >7
</BODY>
</HTML>