为了账号安全,请及时绑定邮箱和手机立即绑定

如果 radiobtnlist 的值为 1,我想启用文本框

如果 radiobtnlist 的值为 1,我想启用文本框

九州编程 2021-11-25 19:34:13
如果 RadioButtonList 的值为零,我有这个代码来禁用文本框。但它不起作用我不知道为什么。<script type="text/javascript">     $(function () {            $("#RadioButtonList1").change(function() {              var st = ("#RadioButtonList1").val();              if (("#RadioButtonList1").val() == "1") {                   $("#TextBox_ArrivalDate").prop("disabled",false);              }else{                  $("#TextBox_ArrivalDate").prop("disabled",true);              }            );       });</script>这是我的 RadioButtonList<asp:Label ID="type" Cssclass="label" runat="server" Text="Please Choose One"></asp:Label><asp:RadioButtonList ID="RadioButtonList1" runat="server" style="margin-left: 47px" Width="153px">    <asp:ListItem Value="1">Round Trip</asp:ListItem>    <asp:ListItem Value="0">One Way</asp:ListItem></asp:RadioButtonList>
查看完整描述

3 回答

?
梦里花落0921

TA贡献1772条经验 获得超6个赞

 $(document).ready(function () {

                $('#RadioButtonList1 input').change(function () {

                    debugger;

                    if ($(this).val() == 1) {

                        $('#TextBox_ArrivalDate').attr("enabled", "enabled");

                    } else {

                        $('#TextBox_ArrivalDate').attr("disabled", "disabled");

                    }

                });

            });


查看完整回答
反对 回复 2021-11-25
?
狐的传说

TA贡献1804条经验 获得超3个赞

希望我的片段可以在任何方面帮助你。祝你今天过得愉快!


<html>


<head>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

  <script type="text/javascript">

    $(function() {

      $("[name=trip]").change(function() {

        var st = $("[name=trip]:checked").val();

        if (st == "1") {

          $("#TextBox_ArrivalDate").prop('disabled', false);

        } else {

          $("#TextBox_ArrivalDate").prop('disabled', true);

        }

      });

    })

  </script>

</head>


<body>

  <input type="radio" name="trip" value="1" checked> roundtrip<br>

  <input type="radio" name="trip" value="0"> one way<br>

  <input type="text" id="TextBox_ArrivalDate">

</body>


</html>


查看完整回答
反对 回复 2021-11-25
?
胡说叔叔

TA贡献1804条经验 获得超8个赞

改变这一行


$("#RadioButtonList1").change(function() 到 $("<%= RadioButtonList1.ClientID %>").change(function()。


ASP.Net 以不同的格式呈现 RadioButton ID。您可以使用此语法在客户端访问单选按钮的 id。


查看完整回答
反对 回复 2021-11-25
  • 3 回答
  • 0 关注
  • 141 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信