我有一个RadCombobox,并且有一个与此关联的radtextbox。我的想法是根据下拉值启用或禁用(允许用户输入值) 这是aspx代码
<telerik:RadComboBox ID="ddlIFDCSolicitatorValue" class="form-control" " runat="server" AutoPostBack="True" Sort="Ascending" AppendDataBoundItems="true" OnClientSelectedIndexChanged="ToggleStateChanged">
</telerik:RadComboBox>
<telerik:RadTextBox runat="server" Width="150" ID="IFDCtxtOtherSolicitor" Enabled="false" />
以下是我拥有的Javascript
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<telerik:RadScriptBlock runat="server">
<script type="text/javascript">
function ToggleStateChanged(sender, args) {
$('.RadComboBox').each(function(i, obj) {
if (obj.id.endsWith('ddlIFDCSolicitatorValue')) {
var toggleButton = $find(obj.id);
var otherSolicitorTxt = $find("<%= IFDCtxtOtherSolicitor.ClientID %>");
switch (args.get_item().get_text().trim()) {
case "Other":
otherSolicitorTxt.setAttribute("disabled", false);
break;
default:
otherSolicitorTxt.setAttribute("disabled", true);
break;
}
}
});
}
</script>
</telerik:RadScriptBlock>