All Type Coding

Search Here

How to unckeck checkboxlist based on last checkbox selection.?

<script type="text/javascript">


        $(document).ready(function () {
            $('#ContentPlaceHolder1_chk').live('click', function () {
                var values = '';
                var $ctrls = document.getElementById('ContentPlaceHolder1_chk').getElementsByTagName("input");
                $('#ContentPlaceHolder1_chk input[type=checkbox]:checked').each(function () {
                    if (values.length == 0) {
                        values = $('label[for=' + this.id + ']').html();
                    }
                    else {
                        values += "," + $('label[for=' + this.id + ']').html();
                    }

                });
                var strarray = values.split(',');
                for (var i = 0; i < strarray.length; i++) {
                    if (strarray[i] == "NA") {
                        var selValue = [1, 2, 3, 4, 5, 6, 7, 8, 9];
                        for (var j = 0; j < selValue.length; j++) {

                            $('input:checkbox[value=' + selValue[j] + ']').removeAttr('checked');
                        }
                    }
                }

            });
        });

    </script>

No comments :

Post a Comment