Compatible with IE and Firefox version of the JS reverse Select multiple selection box _ form Effects

Source: Internet
Author: User
Friends say it's not compatible. I went back last night. Debug a compatible version:
Copy Code code as follows:

<meta http-equiv= "Content-type" content= "text/html; CHARSET=GBK ">
<script language= "JavaScript" >
function Selectit (action) {
var Testform=document.getelementbyid ("Bdkey");
for (var i=0; i<testform.elements.length;i++) {
if (testform.elements[i].type== "checkbox") {
E=testform.elements[i];
E.checked= (action== "SelectAll")? 1: (!e.checked);
}
}
}
</script>
<body>
<form name= "Bdkey" id= "Bdkey" >
<p class= "STYLE1" >
Select All
<input type= "checkbox" Name= "SelectAll" value= "checkbox" onclick= "Selectit (' SelectAll ')" ><br>
Anti-election
<input type= "checkbox" name= "Invest" value= "checkbox" onclick= "Selectit ()" ><br>
Item1
<input type= "checkbox" name= "checkbox" value= "checkbox" >
<br>
Item2
<input type= "checkbox" name= "checkbox" value= "checkbox" ><br>
Item3
<input type= "checkbox" name= "checkbox" value= "checkbox" ><br>
Item4
<input type= "checkbox" name= "checkbox" value= "checkbox" ><br>
Item5
<input type= "checkbox" name= "checkbox" value= "checkbox" >
</p>
</form>
</body>

<ptml> <pead> <meta http-equiv= "Content-type" content= "text/html; CHARSET=GBK "> <script language=" javascript > function Selectit (action) {var testform=document.getelementby Id ("Bdkey"); for (var i=0; i<testform.elements.length;i++) {if (testform.elements[i].type== "checkbox") {E=TESTFO Rm.elements[i]; E.checked= (action== "SelectAll")? 1: (!e.checked); }} </script> </pead> <body> <form name= "Bdkey" id= "Bdkey" > <p class= "STYLE1" & Gt All <input type= "checkbox" Name= "SelectAll" value= "checkbox" onclick= "Selectit (' SelectAll ')" > Anti-select <input type = "checkbox" name= "Invest" value= "checkbox" onclick= "Selectit ()" > Item1 <input "checkbox" type= "checkbox" va lue= "checkbox" > Item2 <input type= "checkbox" name= "checkbox" value= "checkbox" > Item3 <input type= "Chec" Kbox "name=" checkbox "value=" checkbox "> Item4 <input type=" checkbox"Name=" checkbox "value=" checkbox "> Item5 <input type=" checkbox "name=" checkbox "value=" checkbox "> </p> </form> </body>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

This compatibility test I just started with a classic JS multiple-selection box selection of the implementation and analysis of the implementation, that is, through ev.srcelement but failed to debug successfully. So there's the way it is now. Compatibility debugging is partly dependent on the way you implement it, like my way is stupid haha but the simplest is often the most effective. Of course, as a technical pursuit of this, we all like to use a lot of advanced methods. I'm not going to be here.

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.