启用/禁用另一个下拉列表值选择的下拉列表 [英] Enable/disable dropdown on another dropdown list value selection
本文介绍了启用/禁用另一个下拉列表值选择的下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在另一个下拉选项上启用/禁用下拉列表。我写了下面的代码来做同样的事情,但它在我的系统上运行良好,具有所有浏览器兼容性,但在IE8的其他机器上没有。
请建议。
Hi,
I need to enable/disable dropdown on another dropdown selection. I wrote below code to do the same but its working fine on my system with all browser compatibility but not on other machine with IE8.
Please suggest .
///enable disable Payment method dropdown on moneysource dropdown change
if (stepName == "PaymentDetails") {
$("select").each(function () {
if ($(this).parent().attr("controlName") == "Money source") {
$(this).change(function () {
enableDisablePaymentMethod($(this));
});
enableDisablePaymentMethod($(this));
}
});
}
///enable disable Payment method dropdown on moneysource dropdown change
function enableDisablePaymentMethod(dropdown) {
var length = dropdown.children("option").length;
var val = dropdown.val();
$("select").each(function () {
if ($(this).parent().attr("controlName") == "Payment method" || $(this).parent().attr("controlName") == "Payment Method") {
if (length == 0 || val == "") {
$(this).prepend('<option value="Select Money Form" selected="selected">Select Money Form</option.');
$(this).attr("disabled", "disabled");
}
else {
$(this).removeAttr("disabled");
$(this).children("option[value='']").remove();
$(this).children("option[value=Select Money Form]").remove();
}
}
});
}
推荐答案
( 选择)。each(function(){
if (
("select").each(function () { if (
( this )。parent()。attr( controlName )== 资金来源){
(this).parent().attr("controlName") == "Money source") {
( this )。change(function(){
enableDisablePaymentMethod(
(this).change(function () { enableDisablePaymentMethod(
这篇关于启用/禁用另一个下拉列表值选择的下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文