我有这段代码,当选择下拉菜单一时,它会自动填充下拉菜单二。我想将此下拉菜单“ two”锁定为无法手动编辑的位置。这是工作示例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);
});
});

最佳答案

您可以使用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);
    });
});


它可能会帮助您。

10-04 13:04