0
我有两个级联的DropDownList已禁用级联MVC中的DropDownList 3
DD2依赖于DD1。
如果D1不包含所选项目的数据,我该如何禁用DD2?
$(function() {
$('#DD1').change(function() {
var selected1 = $(this).val();
$.getJSON('@Url.Action("GetCiudadList", "ConsultorioSuper", new { Area = "Superusuario", controller = "Consultorio" })', { IdDD: selected }, function (myData) {
var Select2 = $('#DD2');
Select2.empty();
$.each(myData, function (index, itemData) {
citiesSelect.append($('<option/>', {
value: itemData.Value,
text: itemData.Text
}));
});
});
});
})
@Html.DropDownListFor(x => x.SelectedId1, new SelectList(ViewBag.IdUniversidad, "Id1", "Name"), "-- Select --", new { id = "DD1" })
@Html.DropDownListFor(x => x.SelectedId2, new SelectList(Enumerable.Empty<SelectListItem>(), "Id2", "Name"), "-- Select --", new { id = "DD2" })
祝福
您好@Darin季米特洛夫谢谢,但现在,我该如何使DD2如果D1包含数据所选项目? – kalu 2012-07-09 06:51:23
'Select2.removeAttr('disabled');'。我建议你朝着jQuery文档前进,并阅读一些入门教程:http://docs.jquery.com/Main_Page – 2012-07-09 06:55:16