==============================
Jquery
=============================
$(function () {
$("#selectcountryid").change(function () {
debugger;
var selectedcountry = $(this).find("option:selected").text();
$.ajax({
type: "post",
url: "/Administrator/SelectState",
data: {'country': selectedcountry },
success: function (response) {
var item = eval("(" + response + ")");
if (item.length > 0) {
var listitem = '<option value="select">--Select state--</option>';
for (var i = 0; i < item.length; i++) {
listitem = listitem + '<option value="' + item[i].stateid + '">' + item[i].stateName + '</option>'
}
$('#idstate').html(listitem)
}
}
});
});
});
======================================
C# controller view
======================================
public string SelectState(string country = null)
{
string listofsatate = "0";
var objstatelist = (new pushnotification()).SelectState(country);
if (objstatelist.Count > 0)
{
listofsatate = JsonConvert.SerializeObject(objstatelist);
}
return listofsatate;
}
========================================
Jquery
=============================
$(function () {
$("#selectcountryid").change(function () {
debugger;
var selectedcountry = $(this).find("option:selected").text();
$.ajax({
type: "post",
url: "/Administrator/SelectState",
data: {'country': selectedcountry },
success: function (response) {
var item = eval("(" + response + ")");
if (item.length > 0) {
var listitem = '<option value="select">--Select state--</option>';
for (var i = 0; i < item.length; i++) {
listitem = listitem + '<option value="' + item[i].stateid + '">' + item[i].stateName + '</option>'
}
$('#idstate').html(listitem)
}
}
});
});
});
======================================
C# controller view
======================================
public string SelectState(string country = null)
{
string listofsatate = "0";
var objstatelist = (new pushnotification()).SelectState(country);
if (objstatelist.Count > 0)
{
listofsatate = JsonConvert.SerializeObject(objstatelist);
}
return listofsatate;
}
========================================
No comments:
Post a Comment