I do not know why the previous article has been in the audit phase, is there any word is sensitive to the crab?
Anyway, re-write this, it is also a deep memory.
The first thing to write is the full selection of the check box checkbox used in the table data operation today, and to write the following HTML language first
<table> <thead> <tr> <td><input type= "checkbox" id= "Sall" onchange= " Changeall () "></td> </tr> </thead> <tbody> <tr> <td> <input type= "checkbox" Name= "Each" value= "1" ></td> </tr> <tr> <td>< Input type= "checkbox" Name= "Each" value= "2" ></td> </tr> <tr> <td>< Input type= "checkbox" Name= "Each" value= "3" ></td> </tr> <tr> <td>< Input type= "checkbox" Name= "Each" value= "4" ></td> </tr> </tbody> </table >
to write a more simple and straightforward way to read from the web, more than one-fold better than your own.
function Changeall () {var Sall=document.getelementbyid ("Sall");//Gets the action object in the title bar var seach=document.getelementsbyname (" Each ");//Gets the object for the content bar for (Var i=0;i<seach.length;i++) {if (sall.checked) {seach[i].checked=true;} Else{seach[i].checked=false;}}}
to analyze the implementation of its method, than the decisive of their own writing is much better, I took two methods at that time, but far less than the introduction of this molding clear, their full use of ID to operate really smelly and long.
There is a more common check box for the check box, and for the example above, let's do the following: onchange= "Change ()"
function change () {var seach=document.getelementsbyname (' each '); for (Var i=0;i<seach.length;i++) {Seach[i]. checked=!seach[i].checked;}}
Finally, the most commonly used check box is to get a column of information, so as to achieve the value, here we get the following value:
var seach=document.getelementsbyname ("Each"), for (Var i=0;i<seach.length;i++) {if (seach[i].checked) {alert (seach [I].value];
}}
Do not know what they insist on what, so rewrite it again, the effect, it is not the first time to come so good, no matter how much, refueling bar, rookie Fei Fei Fei ....