Javascript toggle checkbox 2 class

I have this html code, 3 checkboxes, the All checkbox is to control 1 & 2 checkbox If I click All checkbox, only checkbox with info[] name changed. What I need is if I change All checkbox, the 1 & 2 checkbox will toggle checked.

All: <input type="checkbox" onchange="togglecheckboxesAll(this,'info[]')"> | 

1 <input type="checkbox" class="check" />
2 <input type="checkbox" name="info[]" class="check2"/>

And here is the javascript code.

PS :

The selector of checkbox 1 is class="check"

The selector of checkbox 2 is name="info[]"

function togglecheckboxesAll(master,group){
    var cbarray = document.getElementsByName(group);
    var cbarray2 = document.getElementsByName('check');
    for(var i = 0; i < cbarray.length; i++){
        cbarray[i].checked = master.checked; 

    for(var a = 0; a < cbarray2.length; a++){
        cbarray2[a].checked = master.checked;

I'm sorry, I don't know much about javascript.



use the classname for the group

 all <input type="checkbox" onChange="togglecheckboxesAll(this,'clickgroup')" />

1 <input type="checkbox" class="check clickGroup" />
2 <input type="checkbox" class="check2 clickGroup" />

function togglecheckboxesAll(master, group){
    var elems = document.getElementsByTagName('input'), i;
    for (i in elems) {
        if((' ' + elems[i].className + ' ').indexOf(' ' + matchClass + ' ')
                > -1) {
            elems[i].checked= master.checked;

Need Your Help

jquery - select all checkboxes with js array name

php jquery arrays forms checkbox

I want to use a JQuery "check all" function in a form like this:

Where Do I Place Google Analytics Code Inside .ASPX Page?

javascript html google-analytics

I just signed up with google analytics and I am trying to find where to add the tracking code on my page. I know how insert in basic html pages, I just have inherited a site that is a .aspx