2012-10-17 6 views
0

계단식 드롭 다운 목록은 Jquery에서 잘 처리되지만 두 번째 dropDown이 변경되면 양식을 제출할 때 문제가 있습니다. 여기에 내 코드가 있습니다. 난 드롭에서 값을 선택하지만, 제 dropwdown 데이터와 두 번째를 채우는 경우, 양식을 제출하지 않는 경우계단식 드롭 다운에 폼을 제출하십시오

$("#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" });} 
         &nbsp; 
        </div> 

       <div class="pull-left"> 
        @Html.Label("Sucursal") 
        @Html.DropDownList("id", Enumerable.Empty<SelectListItem>(),null ,new {name="id", @class="input-medium"}) 
       </div> 
      } 

답변

0
$('#id').change(function() { 
     this.form.submit();; //double semi-colon here, remove and it should be fine 

}); 
+0

덕분에, 난 여전히 같은 제거합니다. – Overmachine

+0

도움이 될만한 HTML이 있습니까? –

+0

예, 방금 HTML을 추가했습니다. – Overmachine

관련 문제