Click here to Skip to main content
16,018,904 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
JavaScript
@Html.DropDownList("ApplicableOn_", new List<SelectListItem>

               {
                  new SelectListItem{ Text="<----Select--->", Value = "0" },
                  new SelectListItem{ Text="Bill", Value = "1" },
                  new SelectListItem{ Text="Product", Value = "2" }
               }, new { style = " width: 100%; height: 22px;", @onchange = "Fillstates()" })

              <script type="text/javascript">

                  function Fillstates() {
                      var Country_id = $('#ApplicableOn_').val();
                      $.ajax({
                          url: 'Fillstates',
                          type: "GET",
                          dataType: "JSON",
                          data: { Country_id: Country_id },
                          success: function (cities) {
                              $("#State_name").html(""); // clear before appending new list
                              $.each(cities, function (i, city) {
                                  $("#State_name").append(
                                      $('<option></option>').val(city.State_id).html(city.State_name));
                              });
                          }
                      });
                  }
              </script>





, can i resolve using same script and html helper

What I have tried:

Just i wanna to do call mentioned java script function on my on change event



, can i resolve using same script and html helper
Posted
Updated 3-Jun-16 2:56am

1 solution

$ is used by jQuery and since the error says it does not know what $ is, that means the jquery.js file is not loaded. You can download it from jQuery[^].
 
Share this answer
 
Comments
Member 10992268 15-Jun-16 1:43am    
thanks RyanDev
ZurdoDev 15-Jun-16 7:19am    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900