JS implements the function of Selecting All check boxes for CheckBox.

Source: Internet
Author: User

JS implements the function of Selecting All check boxes for CheckBox.

Most of the functions are used in the website management background, such as processing multiple products at a time, deleting Articles, and dismounting the products. It is obviously troublesome to set a single point, if you can put a checkbox in each row, it will be much easier to handle it in a unified manner. Today, I will explain the implementation principle and implementation process of this function in a simple space.

The CheckBox control is what we call a check box. It is usually used to open or close an option. This control is available in the "Settings" dialog box of most applications. What we can see is CheckBox.

This control indicates whether a specific status (that is, the option) is selected (on, the value is 1) or cleared (off, the value is 0 ). Use this control in applications to provide users with "True/False" or "yes/no" options. Because checkboxes work independently, you can select any number of checkboxes at the same time for Option combinations.

The CheckBox check box JS achieves the function of selecting all and not selecting all. It is easy to insert a small js function...

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

<Script language = "javascript">

Function cli (Obj)

{

Var collid = document. getElementByIdx_x ("all ")

Var coll = document. getElementsByName (Obj)

If (collid. checked ){

For (var I = 0; I <coll. length; I ++)

Coll [I]. checked = true;

} Else {

For (var I = 0; I <coll. length; I ++)

Coll [I]. checked = false;

}

}

</Script>

Below is a set of CheckBox check box html code

?

1

2

3

4

5

6

7

<Input name = 'Multiple option name' type = 'checkbox' value = ''' id = "all" onclick = "cli ('Multiple option name');"> select all

<Input name = 'option name' type = 'checkbox' value = ''>

<Input name = 'option name' type = 'checkbox' value = ''> B

<Input name = 'option name' type = 'checkbox' value = ''> C

<Input name = 'option name' type = 'checkbox' value = ''> D

<Input name = 'option name' type = 'checkbox' value = ''> E

<Input name = 'option name' type = 'checkbox' value = ''> F

Now, you can copy the above Code and modify and test it...

The above is all the content of this article. I hope you will like it.

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.