0

HI i have 4 gridview in one form...i have to check all text field if someone select main check box...
my code is working only on one grid view..its not working on other grid view.
what should i do?
my code is

<script type="text/javascript">

 function checkAll(chkid) 
    {
        var chk = document.getElementById(chkid);



        var allchk = document.getElementsByName("contacts");
        for (var i = 0; i < allchk.length; i++) {
            allchk[i].checked = chk.checked;
        }


    }




 </script>

Regards..
Farhad

3
Contributors
2
Replies
4
Views
4 Years
Discussion Span
Last Post by code739
0

@Farhad.idrees

i have to check all text field if someone select main check box...

You can try this (I test it on my end and it works fine the only difference is that you provided a different var than mines, so keep that in mind):

<script type="text/javascript">
    function checkedAll () {
        var chk = document.getElementsById('chkid');
        var checkboxes = [];
        var check = document.getElementByName('contacts').checked
        for (var i = 0; i < allchk.length; i++) {
            if (chkid[i].type == 'checkbox') {
                chkid[i].checked = check;
            }
        }
    }
</script>
0

try this common function to check or uncheck input checkbox from 'formname' form

 function checkAll(){
        var inputTags = formname.getElementsByTagName('input'); 

        for (var i=0, length = inputTags.length; i<length; i++) {
             if (inputTags[i].type == 'checkbox') {
                 if(inputTags[i].checked==true){
                    inputTags[i].checked = false;
                 }else{

                    inputTags[i].checked = true;
                 }
             }
        }

     }

Edited by code739

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.