zoukankan      html  css  js  c++  java
  • Jquery 获取CheckBoxList 中选择的值和获取RadioButton 选中的状态

        
    <tr>
                    <td class="td_text" style=" 150px;">
                        工程承包内容:
                    </td>
                    <td colspan="3" style=" 600px;">
                        <asp:CheckBoxList ID="chkGcnr" runat="server" Height="20px" class="{required:true,messages:{required:'请选择工程承包内容!'}}" Width="550px" RepeatDirection="Horizontal">
                            <asp:ListItem Value="ytgckc" ClassAtt="tab_zbb_htdj_kc.gcnr_ytgckc">岩土工程勘察</asp:ListItem>
                            <asp:ListItem Value="ytgcsj" ClassAtt="tab_zbb_htdj_kc.gcnr_ytgcsj">岩土工程设计</asp:ListItem>
                            <asp:ListItem Value="ytgccs" ClassAtt="tab_zbb_htdj_kc.gcnr_ytgccs">岩土工程测试、监测、检测
                            </asp:ListItem>
                            <asp:ListItem Value="ytgczx" ClassAtt="tab_zbb_htdj_kc.gcnr_ytgczx">岩土工程咨询、监理</asp:ListItem>
                            <asp:ListItem Value="swdzkc" ClassAtt="tab_zbb_htdj_kc.gcnr_swdzkc">水文地质勘察</asp:ListItem>
                            <asp:ListItem Value="gccl" ClassAtt="tab_zbb_htdj_kc.gcnr_gccl">工程测量
                            </asp:ListItem>
                            <asp:ListItem Value="ytgczl" ClassAtt="tab_zbb_htdj_kc.gcnr_ytgczl">岩土工程治理
                            </asp:ListItem>
                            <asp:ListItem Value="gczt" ClassAtt="tab_zbb_htdj_kc.gcnr_gczt">工程钻探
                            </asp:ListItem>
                            <asp:ListItem Value="gczj" ClassAtt="tab_zbb_htdj_kc.gcnr_zj">凿井
                            </asp:ListItem>
                        </asp:CheckBoxList>
                    </td>
                </tr>
    获取函数
      var gcnrtext = "";
                $("#<%=chkGcnr.ClientID%> span").each(function (string) {
                    if ($(this).children().eq(0).is(':checked') == true) {
                        gcnrtext = gcnrtext + $(this).children().eq(1).text() + ";";
                    }
                });

    恶心变态的问题来了
    CheckBoxList 初次加载带有span标签可以取到值, 第二次生成就没有span标签


    所以此方法修改后为:
      $("#<%=chkGcnr.ClientID%> input").each(function (string) {
                    if ($(this).is(':checked') == true) {
                        gcnrtext = gcnrtext + $(this).parent().find("label").text() + ";";
                    }
                  });

       <asp:RadioButton ID="rdoCk" runat="server" Text="初勘" GroupName="rdo" />
       <asp:RadioButton ID="rdoXk" runat="server" Text="详勘" GroupName="rdo" />

      if (document.getElementById("<%=rdoCk.ClientID%>").checked == true )
  • 相关阅读:
    $.ajax
    es6--之箭头函数
    vuex相关知识点
    grunt---grunt_test 测试用例
    git2--常用命令
    git命令
    百万程序员的苦恼-选择VB.NET还是C#
    在Linux上运行C#
    C#中的cookie编程
    C#编程让Outlook乖乖交出帐户密码
  • 原文地址:https://www.cnblogs.com/hui721/p/4548629.html
Copyright © 2011-2022 走看看