Get the text value of the checkbox

Source: Internet
Author: User

If you see a problem on the internet, try to get the checkbox value. The technology is not very difficult, but you have time to do exercises.
Create a webpage:

Write the click event. When the checkbox is selected, the text value of the checkbox is obtained. Otherwise, the textbox value is cleared:



Real-time Demonstration:



What if the requirement is not to directly access the checkbox, but to access the checkbox in the DIV label? To try:

In fact, after adding the DIV tag control, you can still obtain the checkbox value using the above method. However, we want to get it from the DIV control. How can we implement it?
You can cycle all controls in the DIV control. because there may be other controls in the DIV control, you must determine whether the same is a checkbox control:


In the preceding example, the checkbox control is only placed in a div control. If it is stored in a deep control, do we need several foreach (control CTL in div1.controls) or is the findcontrol () method used to find the checkbox?

You don't have to worry about this. There is a way for you to quickly find the target, reference here "not using the findcontrol method to find deep nested controls" http://www.cnblogs.com/insus/archive/2012/09/27/2705388.html its upgrade article "not using the findcontrol method to find deep nested controls ver2" http://www.cnblogs.com/insus/archive/2012/10/07/2713568.html

 

Get the text value of the checkbox

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.