0
我有一個級聯dropdown下載列表在jquery中完成他們工作得很好,但我有一個提交表單時第二dropDown更改,這裏是我的代碼的問題。當我從下拉的值,但是當第一dropwdown填充數據第二個,它不提交表單級聯DropDown更改提交窗體Jquery
$("#Bank").change(function() {
var bankId = $(this).val();
$.ajax("/App/BankBranch/ByBank", {
data: { "id": bankId },
type: "get", contentType: "application/json",
success: function (result) {
var options = $("#id");
options.html("");
$.each(result, function() {
options.append($("<option />").val(this.Id).text(this.Name));
});
}
});
}).trigger('change'); //to make the event run on initialization for default value
$('#id').change(function() {
this.form.submit();
});
形式只提交。
更新 添加HTML
<h2>@ViewBag.Title</h2>
<h4>Seleccione Sucursal</h4>
@using (Html.BeginForm(null, null, FormMethod.Get))
{
<div class="pull-left">
@Html.Label("Banco")
@{Html.RenderAction("GetAllBanks", "Bank", new { ControlName = "Bank" });}
</div>
<div class="pull-left">
@Html.Label("Sucursal")
@Html.DropDownList("id", Enumerable.Empty<SelectListItem>(),null ,new {name="id", @class="input-medium"})
</div>
}
感謝,我將其刪除,仍然是相同的。 – Overmachine
你有一些HTML幫助? –
是的,我只是添加HTML – Overmachine