Uncheck dynamically created checkboxes

Uncheck dynamically created checkboxes

Hi All,

I've created a dynamic grid in my mvc page and for each record, there is a checkbox in the row. Apart from that, there's one additional record for another checkbox 'None of the above'. 
What i need is when i click on checkbox 'None of the above' all other checkboxes should get uncheck and disabled. And once its unchecked all other checkboxes should get enabled.
Below is the code I've used for your reference




        function DisplayDLMembers() {
            $.ajax
            ({
                url: '../../UserProfile/SearchCompanyAndContact',
                type: 'POST',
                traditional: true,
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                success: function (result) {
                    var htmlStr = "";

                    var DLMappingResult = $("#hdnDLMappingResult").val();

                    if (result.DLCompnayContactDetail.length > 0) {

                        htmlStr = '<table width="100%" border="0" cellspacing="0" cellpadding="0" id="searchgrid" class="grid"><tr><th align="left">Select</th><th align="left">Name</th><th align="left">Company/Organization</th><th align="left">Mailing Address</th><th style="text-align: center">Email/Alternate Email Address</th><th style="text-align: center">Associated Matter/Dockets</th>'

                        var MemberNames = $("#hdnMemberNames").val();
                        var MemberSeqList = $("#hdnMemberSeqList").val();

                        $.each(result.DLCompnayContactDetail, function (i, item) {
                            htmlStr = htmlStr.concat('<tr> <td align="left" valign="top">');
                            if (MemberNames.indexOf(item.Name) >= 0 & MemberSeqList.indexOf(item.MemberSeq) >= 0) {
                                htmlStr = htmlStr.concat('<input type="checkbox" class="checkbox" checked = "checked" value="' + item.MemberSeq + ':' + item.Name + '" name="chkSelectDLMember" /></td>');
                            } else {
                                htmlStr = htmlStr.concat('<input type="checkbox" class="checkbox" value="' + item.MemberSeq + ':' + item.Name + '" name="chkSelectDLMember" /></td>');
                            }
                            htmlStr = htmlStr.concat('<td align="left" valign="top">' + item.Name + '</td>');
                            htmlStr = htmlStr.concat('<td align="left" valign="top">' + item.CompanyOrganization + '</td>');
                            htmlStr = htmlStr.concat('<td align="left" valign="top">' + item.MailingAddress + '</td>');
                            if (item.AlternateEmail == "") {
                                htmlStr = htmlStr.concat('<td  style="text-align: center" valign="top">' + item.Email + '</td>');
                            } else {
                                htmlStr = htmlStr.concat('<td  style="text-align: center" valign="top">' + item.Email + ',' + item.AlternateEmail + '</td>');
                            }

                            if (item.HasAssociatedMatterDockets == "Y") {
                                htmlStr = htmlStr.concat('<td  style="text-align: center" valign="top"><a href="/Common/AssociatedMatterDocket?MemberSeq=' + item.MemberSeq + '" target="_blank">View</a></td>');
                            } else {
                                htmlStr = htmlStr.concat('<td  style="text-align: center" valign="top"></td>');
                            }
                            khtmlStr = htmlStr.concat('</tr>')
                        });

                        //Add None of the above
                        htmlStr = htmlStr.concat('<tr> <td align="left" valign="top">');
                        htmlStr = htmlStr.concat('<input type="checkbox" class="checkbox" value=1 name="chkSelectNoneDLMember" onchange="SetCheckboxes()" /></td>');
                        htmlStr = htmlStr.concat('<td align="left" valign="top">None of the above</td>');
                        htmlStr = htmlStr.concat('<td align="left" valign="top">&nbsp;</td>');
                        htmlStr = htmlStr.concat('<td align="left" valign="top">&nbsp;</td>');
                        htmlStr = htmlStr.concat('<td align="left" valign="top">&nbsp;</td>');
                        htmlStr = htmlStr.concat('<td align="left" valign="top">&nbsp;</td>');
                        htmlStr = htmlStr.concat('</tr>')

                        htmlStr = htmlStr + '</table>'

                        $("#SearchResult").html(htmlStr);
                        document.getElementById("SearchResult").style.display = "block";
                    }
                }
            });
        }

        function SetCheckboxes() {
            debugger;
            var objchk = $("input:checkbox[name=chkSelectNoneDLMember]:checked").val();
            //var objchk = document.getElementById('chkSelectNoneDLMember');
            //if ($("#chkSelectNoneDLMember").is(':checked')) {
            //if ($('#chkSelectNoneDLMember').attr('checked')) {
            //if (this.checked) {
            if (objchk == undefined) {
                alert('chkSelectNoneDLMember unchecked');
                $('#chkSelectDLMember').attr('disabled', false);
                var checkBoxes = $(this).siblings('input[type=checkbox]');
                checkBoxes.prop('disabled', false);
            } else {
                alert('chkSelectNoneDLMember checked');
                var checkBoxes = $(this).siblings('input[type=checkbox]');
                checkBoxes.prop('checked', false);
                checkBoxes.prop('disabled', true);
                //$('#chkSelectDLMember').attr('checked', false);
                //$('#chkSelectDLMember').attr('disabled', true);
            }
        }