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 )
  • 相关阅读:
    Kubernetes 集成研发笔记
    Rust 1.44.0 发布
    Rust 1.43.0 发布
    PAT 甲级 1108 Finding Average (20分)
    PAT 甲级 1107 Social Clusters (30分)(并查集)
    PAT 甲级 1106 Lowest Price in Supply Chain (25分) (bfs)
    PAT 甲级 1105 Spiral Matrix (25分)(螺旋矩阵,简单模拟)
    PAT 甲级 1104 Sum of Number Segments (20分)(有坑,int *int 可能会溢出)
    java 多线程 26 : 线程池
    OpenCV_Python —— (4)形态学操作
  • 原文地址:https://www.cnblogs.com/hui721/p/4548629.html
Copyright © 2011-2022 走看看