How to call single javascript function for different <div> tags?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saadkhan
    New Member
    • Aug 2008
    • 40

    #1

    How to call single javascript function for different <div> tags?

    I`v made the following code:
    Code:
    <div id="Panels" style="width: 28%;"> 
                <asp:Panel ID="one" runat="server" CssClass="Panel"> 
                    <div id="Head" onclick="doToggle();"> 
                        HEADER 
                    </div> 
                </asp:Panel> 
                <asp:Panel ID="two" runat="server" CssClass="Content"> 
                        abcdefghijklmnopqrstuvwxyz 
               </asp:Panel> 
                <cc1:CollapsiblePanelExtender ID="cpe" runat="server"  TargetControlID="two"></cc1:CollapsiblePanelExtender> 
    </div>
    and the function doToggle() is:
    Code:
    <script type="text/javascript"> 
            function doToggle() 
            { 
                var cpe = $find("cpe"); 
    
                if (cpe.get_Collapsed())  
                {    
                    cpe._doOpen(); 
                }  
                else 
                { 
                    cpe._doClose(); 
                } 
            } 
        </script>
    Actually i want to use single 'CollapsiblePan elExtender' for many <div> tags, that is i just need to specify in function the targetId of div tags to act on everytime from where the function is called....
    Last edited by jhardman; Oct 2 '08, 07:06 PM. Reason: put code in code tags. please note button marked #, moved thread to .NET forum
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Consider using an Accordion Extender instead??

    -Frinny

    Comment

    Working...