zoukankan      html  css  js  c++  java
  • 使用jQuery方便的统计Repeater列的总和

        <script type="text/javascript">              
                $(function () {              
                    StatSum("lblAAcount", "spAAcount");  
                    StatSum("lblBBcount", "spBBcount");  
                }  
                function StatSum(lblId, spId) {  
                    var sum = 0;  
                    $("span[id$='" + lblId +"']").each(function () {  
                        sum += parseInt($(this).text());  
                    });  
                    $("#" + spId).text(sum);  
                }  
        </script>  
        <asp:Repeater ID="rptTest" runat="server" >  
           <HeaderTemplate>  
             <table>                                  
               <tr>  
                <th>年度</th>                                     
                <th>AA总人数</th>  
                <th>BB总人数</th>                                      
               </tr>  
           </HeaderTemplate>  
           <ItemTemplate>  
              <tr>  
               <td><%#Eval("year")%></td>  
               <td><asp:Label runat="server" ID="lblAAcount" Text='<%#Eval("AAcount")%>'></asp:Label></td>  
               <td><asp:Label runat="server" ID="lblBBcount" Text='<%#Eval("BBcount")%>'></asp:Label></td>  
              </tr>  
           </ItemTemplate>  
           <FooterTemplate>  
              <tr>  
                <td>合计</td>  
                <td><span id="spAAcount"></span></td>  
                <td><span id="spBBcount"></span></td>  
              </tr>  
             </table>  
            </FooterTemplate>  
        </asp:Repeater>  
    
  • 相关阅读:
    C语言01
    C++面试总结更新
    Python网络爬虫与信息提取02
    Self-Driving Car 01
    Python网络爬虫与信息提取01
    Python-03
    Shell
    Python-05
    Python-04
    Python-02
  • 原文地址:https://www.cnblogs.com/gdjlc/p/2086901.html
Copyright © 2011-2022 走看看