Select all multiple selection boxes for js compatible with ie and firefox versions

Source: Internet
Author: User

Friends said it was incompatible. I went back to debug a compatible version last night:
Copy codeThe Code is as follows:
<Html>
<Head>
<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>
</Head>
<Body>
<Form name = "bdkey" id = "bdkey">
<P class = "STYLE1">
Select All
<Input type = "checkbox" name = "selectAll" value = "checkbox" onClick = "selectIt ('selectall')"> <br>
Invert Selection
<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>

<Html> <pead> <meta http-equiv = "Content-Type" content = "text/html; charset = gbk"> </pead> <body> </body>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
At the beginning of this compatibility test, I used a classic js multi-choice box all-selected reverse selection implementation and analysis implementation method, that is, through ev. srcElement, but the debugging was not successful. So we have the current method. Compatibility debugging is partly dependent on your implementation method. I am a fool, but the simplest is often the most effective. Of course, as the pursuit of technology, we all like to use many advanced methods. I won't

Related Article

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.