javascript - 如果 radiobtnlist 的值为 1,我想启用文本框
问题描述
如果 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>
解决方案
将这一行从
$("#RadioButtonList1").change(function() 到 $("<%= RadioButtonList1.ClientID %>").change(function().
ASP.Net 以不同的格式呈现 RadioButton ID。您可以使用此语法访问客户端单选按钮的 id。
推荐阅读
- sql - 对 select 子句中的一长串后续列执行计算的最佳方法
- apache-kafka - 重新平衡后的 KafkaStream stateStore 陈旧数据
- asp.net-core - 在 IIS 上托管 asp.net core 2.2 应用程序会出现错误 500
- php - 无法使用 LDAP 包 Adldap2-Laravel 登录 laravel
- ruby-on-rails - 在 Ruby on Rails 中使用 Chromedriver 时出错
- node.js - 套接字 IO 错误“对 XMLHttpRequest 的访问已被 CORS 策略阻止”
- android - 使用此 map.setMyLocationEnabled(true); 时总是出错 它不工作
- ionic3 - 添加背景地理定位插件后,Ionic 3 空白应用程序无法构建到 Android
- git - Git LFS 不一致?
- java - 如何在 Maven 中从命令提示符传递 aws 环境变量