我在这里使用Mvc与JQUERY请帮助我如何从状态dropdownList获取State_Id
@using (Html.BeginForm("SaveEmployee", "Customer", FormMethod.Post, new { @class = "form-horizontal" }))
{
<b>Country</b>
@Html.DropDownListFor(cnt => cnt.SaveEmployee.Cnt_Id, new SelectList(Model.GetCountry, "Cnt_Id", "Cnt_Name"),"Select Country")
<b>State</b> <select id="DDlState" class="form-control"></select>
这里当我的国家Drp更改其获取状态值但是当我点击提交btn时我没有能够2绑定stateId
JqueryCode
var ddlStates = $('#DDlState');
ddlStates.append($('<option/>', { value: "-1", text: "Please Select State" }))
$.ajax({
url: 'http://localhost:47237/Customer/GetStateById/' + stsId,
method: 'GET',
dataType: 'Json',
// data:stsId,
}).success(function (data) {
console.log(data);
$.each(data,function (i,Items) {
$(ddlStates).append($('<option/>', { value: Items.Sts_Id, text: Items.Sts_Name }))
ddlStates.attr('disabled', false);
})
答案 0 :(得分:0)
请提供
<select id="DDlState" class="form-control" name="SaveEmployee.Sts_Id"></select>
我希望它会起作用