Abhilash J A

Abhilash J A

  • 530
  • 2.4k
  • 600.5k

Problem to change two dropdownlist based on another jQuery

Jun 17 2016 1:25 AM
Hello Sir,<br /><br />I have two dropdownlist select2 based on another. But second drownlist do not working properly in MVC4.<br /><br /> @Html.DropDownList("company11", ViewData["companyy"] as List&lt;SelectListItem&gt;,"Select",new { @class = "validate[required]" })<br /> @Html.DropDownList("brand11", ViewData["brandss"] as List&lt;SelectListItem&gt;,"Select",new { @class = "validate[required]" })<br /><br />This jquery code:<br /><br /> $("#company11").change(function () {<br /> checkUserIdentity();<br /> var id = $(this).val();<br /> binddropdownn_branch(id);<br /> <br /> });<br /><br /> function binddropdownn_branch(id) {<br /><br /> $.ajax({<br /> type: "POST",<br /> url: '/Product/GetbarnchList?id=' + id,<br /> data: {},<br /> contentType: "application/json; charset=utf-8",<br /> dataType: "json",<br /> async: false,<br /> success: function (result) {<br /><br /> $("#brand11").find('option').remove();<br /><br /> $.each(result, function () {<br /><br /> var option = $("&lt;option/&gt;");<br /> option.attr("value", this.Value).text(this.Text);<br /> $('#brand11').append(option);<br /><br /> });<br /><br /><br /> }<br /> });<br /><br /> }<div></div><div>&nbsp;</div><div>Kindly reply me.</div>

Answers (2)