我有这个代码,当选择下拉列表时,它会自动填充下拉列表中的两个。我想把这个下拉锁定在两个'无法手动编辑的地方。以下是工作示例http://jsfiddle.net/k4hYE/54/
var objArray = {"On-Call Service": "Per Pickup",
"Every Six Months (2 Stops Annually)": "Per Pickup",
"Every Three Months (4 Stops Annually)": "Every Three Months",
"Every Other Month (6 Stops Annually)": "Every Other Month",
"Monthly (12-13 Stops Annually)": "Per Month",
"Every Other Week (26 Stops Annually)": "Per Month",
"Every Week (52 Stops Annually)": "Per Month"};
$("#00NA00000047Jk8").change(function()
{
var ddText = $(this).val();
$.each(objArray,function(key,value)
{
if(ddText == key)
$("#00NA0000005wIiU").val(value);
});
});
答案 0 :(得分:1)
你可以使用prop('disabled', true)
它会禁用下拉列表,因此无法手动更改。
检查以下代码。
$("#00NA00000047Jk8").change(function()
{
var ddText = $(this).val();
$.each(objArray,function(key,value)
{
if(ddText == key)
$("#00NA0000005wIiU").val(value);
$("#00NA0000005wIiU").prop('disabled', true);
});
});
它可能对你有帮助。