亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如果 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 關注
  • 164 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號