Hi Friends,
I built one mvc5 application with three cascading dropdown list, like country,state,city.
now what i need is if i select country dropdown list means state dropdown list wants to enable.and so far for state dropdown to city dropdown.
But by default state and city dropdown list is disabled. Thanks in Advance
here is my jquery:
function OnCountryChange(e)
{
var selectedCountryId = $(e).val();
var ddlStates = "#sname ";
$.ajax({
url: '@Url.Action("LoadStateList", "Home")',
type: 'get',
dataType: 'json',
contentType: 'application/json',
cache: false,
data: { "CountryId": selectedCountryId },
success: function (data) {
$( ddlStates).empty();
$.each(data, function (i, foo) {
$(ddlStates).append(
$("<option></option>").val(foo.Value).html(foo.Text)
);
});
},
error: function (xhr, ajaxOptions, thrownError) {
}
});
}
function OnStateChange(e) {
var selectedStateId = $(e).val();
var ddlStates = "#ciname";
$.ajax({
url: '@Url.Action("LoadCityList", "Home")',
type: 'get',
dataType: 'json',
contentType: 'application/json',
cache: false,
data: { "StateId": selectedStateId },
success: function (data) {
$(ddlStates).empty();
$.each(data, function (i, foo) {
$(ddlStates).append(
$("<option></option>").val(foo.Value).html(foo.Text)
);
});
},
error: function (xhr, ajaxOptions, thrownError) {
}
});
}