Implement full checkbox Selection in asp.net

Source: Internet
Author: User

In asp.net, the server control automatically generates the ID and name attributes. Therefore, it is more difficult to use javascrip to achieve full selection.
By searching for information, I think it is relatively simple to use javascrip + jquery in combination to implement it from a simple perspective.
The following code is used:
[Javascript]
Function quanxuan (){
Var obj = document. getElementById ("btnSelectAll ");
If (obj. value = "select all "){
$ ("Input: checkbox"). attr ("checked", true); // set all to selected
Obj. value = "cancel"
 
}
Else {
$ ("Input: checkbox"). attr ("checked", false); // set all to unselected
Obj. value = "select all"
}
 
}

Call code:
[Html] www.2cto.com
<Input type = "button" id = "btnSelectAll" value = "select all" class = "input_btn_search" onclick = "quanxuan ()"/>

Of course, my practice is rough. I have selected all the checkpoints in the document. If you want to select a specific checkbox, such as a check box in a table, you can use the jquery selector to filter. For example:
[Html]
$ ("Table: checkbox ")


Author: lzjpc500

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.