JavaScript Select all and reverse selection

Source: Internet
Author: User

<title> full selection and reverse selection </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<script type= "Text/javascript" language= "JavaScript" >
--Column header full marquee clicked---
function Chkallclick (sonname, Cballid) {
var Arrson = Document.getelementsbyname (sonname);
var cball = document.getElementById (cballid);
var tempstate = cball.checked;
for (i = 0; i < arrson.length; i++) {
if (arrson[i].checked! = tempstate)
Arrson[i].click ();
}
}

--The subkey check box is clicked---
function Chksonclick (sonname, Cballid) {
var Arrson = Document.getelementsbyname (sonname);
var cball = document.getElementById (cballid);
for (var i = 0; i < arrson.length; i++) {
if (!arrson[i].checked) {
cball.checked = false;
Return
}
}
Cball.checked = true;
}

--Anti-select---
function Chkoppclick (sonname) {
var Arrson = Document.getelementsbyname (sonname);
for (i = 0; i < arrson.length; i++) {
Arrson[i].click ();
}
}
</script>

<body>
<form id= "Form1" runat= "Server" >
<input name= "Chkall" id= "Chkall" title= "Select All" onclick= "Chkallclick (' Chkson ', ' Chkall ')" type= "checkbox"/> Select all

<input name= "Chkopposite" id= "chkopposite" title= "reverse select" onclick= "Chkoppclick (' Chkson ')" type= "checkbox"/> Reverse Selection

<input type= "button" id= "Add" name= "Add" onclick= "Addtowish ()" value= "Add"/>
<br/>
<%for (int i = 0; i < ten; i++)
{%>
<input name= "Chkson" id= ' chkson<%=i+1%> ' type= "checkbox" value= ' <%=i+1%> ' onclick= ' ChkSonClick (' Chkson ', ' Chkall ') "/><%=i+1%>
<br/>
<%}%>
</form>
</body>

JavaScript Select all and reverse selection

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.