0

I have three different checkbox list on my web page. I want to have a checkbox that says "select All" and when that check box is checked then all three checkbox list checkboxes are checked. I was looking at this example that checks one checkbox list by clicking on select button, but I want all three checkbox list checkboxes to be checked in javascript. Below is my code

 <asp:CheckBox ID="chkCheckAll" runat="server" Text="Check/Uncheck All"  
                                        Style="font-weight: 700"      CausesValidation="false" oncheckedchanged="chkCheckAll_CheckedChanged" AutoPostBack="true" 
                                          />

   <asp:CheckBoxList ID="chkList_MetricsSeverity" runat="server"   RepeatDirection="Horizontal"
                                                RepeatColumns="3" Width="1060px">
                                            </asp:CheckBoxList>

 <asp:CheckBoxList ID="chkList_MetricsAvgMedian" runat="server" RepeatDirection="Horizontal"
                                                RepeatColumns="3" Width="1060px">
                                            </asp:CheckBoxList>

 <asp:CheckBoxList ID="chkList_Counts" runat="server" RepeatDirection="Horizontal"
                                                RepeatColumns="3" Width="1060px">
                                            </asp:CheckBoxList>

any help will be appreciated

0

2 Answers 2

2

Have a look here...You can find the way to implement above stuff in both asp.net and javascript way......

Sign up to request clarification or add additional context in comments.

1 Comment

I already saw that article, but it only for one checkbox list. i need to pass the id for multiple checkboxlist in the javascript function. I don't know how to do that.
0

This is what needs to eb done. below is the code

  function CheckAll() {


        var chkbx = document.getElementById('<%=chkCheckAll.ClientID %>');

        var chkbxList1 = document.getElementById('<%=chkList_MetricsSeverity.ClientID %>');

        var chkbxList2 = document.getElementById('<%=chkList_MetricsAvgMedian.ClientID %>');

        var chkbxList3 = document.getElementById('<%=chkList_Counts.ClientID %>');
        if (chkbx.checked == true) {
            var chkbxListCount = chkbxList1.getElementsByTagName('input');
            for (var i = 0; i < chkbxListCount.length; i++) {
                chkbxListCount[i].checked = true;
            }
            var chkbxListCount = chkbxList2.getElementsByTagName('input');
            for (var i = 0; i < chkbxListCount.length; i++) {
                chkbxListCount[i].checked = true;
            }
            var chkbxListCount = chkbxList3.getElementsByTagName('input');
            for (var i = 0; i < chkbxListCount.length; i++) {
                chkbxListCount[i].checked = true;
            }
        }
        else {
            var chkbxListCount = chkbxList1.getElementsByTagName('input');
            for (var i = 0; i < chkbxListCount.length; i++) {
                chkbxListCount[i].checked = false;
            }
            var chkbxListCount = chkbxList2.getElementsByTagName('input');
            for (var i = 0; i < chkbxListCount.length; i++) {
                chkbxListCount[i].checked = false;
            }
            var chkbxListCount = chkbxList3.getElementsByTagName('input');
            for (var i = 0; i < chkbxListCount.length; i++) {
                chkbxListCount[i].checked = false;
            }
        } 




    }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.