SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem in radiobuttonlist

    Hello,
    i m using c# asp.net 2.0

    i have one form name search.aspx

    in which i have taken the below radiobuttonlist and checkboxlist....now i want to select automatically all the checkbox item if the radiobuttonlist item is checkall and if the user selects uncheck then it should not select checkbox item. By default i want checkall. how to do this?

    <asp:RadioButtonList ID="rdbtnCheck" runat="server" CssClass="fieldtext" ForeColor="IndianRed" RepeatDirection="Horizontal" OnSelectedIndexChanged="rdbtnCheck_SelectedIndexChanged">
    <asp:ListItem Selected="True">CheckAll</asp:ListItem>
    <asp:ListItem>Uncheck All</asp:ListItem>
    </asp:RadioButtonList>

    <asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatColumns="3" RepeatDirection="Horizontal"
    Width="100%" BorderStyle="Solid" CellPadding="2" CellSpacing="2" CssClass="fieldtext">
    <asp:ListItem Selected="True">User Name</asp:ListItem>
    <asp:ListItem Selected="True">EmpId</asp:ListItem>
    <asp:ListItem Selected="True">Status</asp:ListItem>
    <asp:ListItem Selected="True">Priority</asp:ListItem>
    <asp:ListItem Selected="True">Ticket Id</asp:ListItem>
    <asp:ListItem Selected="True">Severity</asp:ListItem>
    <asp:ListItem Selected="True">Group Name</asp:ListItem>
    <asp:ListItem Selected="True">Category</asp:ListItem>
    <asp:ListItem Selected="True">Subcategory</asp:ListItem>
    <asp:ListItem Selected="True">Application</asp:ListItem>
    <asp:ListItem Selected="True">Asset No</asp:ListItem>
    <asp:ListItem Selected="True">Description</asp:ListItem>
    <asp:ListItem Selected="True">Assigned To</asp:ListItem>
    <asp:ListItem Selected="True">Resolved By</asp:ListItem>
    <asp:ListItem Selected="True">Attachment</asp:ListItem>
    </asp:CheckBoxList>

  2. #2
    SitePoint Addict kunalraj's Avatar
    Join Date
    Nov 2008
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <script type="text/javascript" language="javascript">
        
            function selectAll(involker) {
         
            var inputElements = document.getElementsByTagName('input');
    
            for (var i = 0 ; i < inputElements.length ; i++) {
    
                var myElement = inputElements[i];
    
                if (myElement.type == "checkbox") {
                
                    myElement.checked = involker.checked;
                }
            }
    
        }
        
        
        function deselectAll(involker) {
         
            var inputElements = document.getElementsByTagName('input');
    
            for (var i = 0 ; i < inputElements.length ; i++) {
    
                var myElement = inputElements[i];
    
                if (myElement.type == "checkbox") {
                
                    myElement.checked = involker.unchecked;
                }
            }
    
        }
        
       </script> 
    
    
    <asp:RadioButtonList ID="rdbtnCheck" runat="server" CssClass="fieldtext" ForeColor="IndianRed" RepeatDirection="Horizontal" >
    <asp:ListItem onclick="selectAll(this)" Selected="True">CheckAll</asp:ListItem>
    <asp:ListItem onclick="deselectAll(this)">Uncheck All</asp:ListItem>
    </asp:RadioButtonList>
    
    <asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatColumns="3" RepeatDirection="Horizontal"
    Width="100&#37;" BorderStyle="Solid" CellPadding="2" CellSpacing="2" CssClass="fieldtext">
    <asp:ListItem Selected="True">User Name</asp:ListItem>
    <asp:ListItem Selected="True">EmpId</asp:ListItem>
    <asp:ListItem Selected="True">Status</asp:ListItem>
    <asp:ListItem Selected="True">Priority</asp:ListItem>
    <asp:ListItem Selected="True">Ticket Id</asp:ListItem>
    <asp:ListItem Selected="True">Severity</asp:ListItem>
    <asp:ListItem Selected="True">Group Name</asp:ListItem>
    <asp:ListItem Selected="True">Category</asp:ListItem>
    <asp:ListItem Selected="True">Subcategory</asp:ListItem>
    <asp:ListItem Selected="True">Application</asp:ListItem>
    <asp:ListItem Selected="True">Asset No</asp:ListItem>
    <asp:ListItem Selected="True">Description</asp:ListItem>
    <asp:ListItem Selected="True">Assigned To</asp:ListItem>
    <asp:ListItem Selected="True">Resolved By</asp:ListItem>
    <asp:ListItem Selected="True">Attachment</asp:ListItem>
    </asp:CheckBoxList>

    Please put this type of thread into javascript thread.
    this will solve your problem.

    thanks,
    kunalraj

  3. #3
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Location
    Cape Town, South Africa
    Posts
    2,873
    Mentioned
    44 Post(s)
    Tagged
    0 Thread(s)
    What exactly do you need help with? Making them all checked by default? Or the "select all" check box as kunalraj gave you the code for above?

  4. #4
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank u so much


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •