ondown on dropdownlist

我的问题是继续我所要求的链接。 加载国家/州/市

我已经扩展到从db加载我的下拉列表,我只需要一种方法在我的第一个下拉列表中连接onchange方法,其次,请参阅代码。 感谢任何帮助。

附加最新代码:

 

$(document).ready(function() { var options = { type: "POST", url: "SearchPage.aspx/LoadCountry", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { var returnedArray = msg.d; country = $("#country"); country.append('Select a Country'); for (i = 0; i < returnedArray.length; i++) { country.append("" + returnedArray[i].Name + ""); } } }; $.ajax(options); }); function getStateByCountryId() { $("#country").change(function() { var _selected = $("#country").val(); var options = { type: "POST", url: "SearchPage.aspx/StateBy", data: "{'countryId':'" + _selected + "'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { $('#state').empty(); var returnedArray = msg.d; state = $("#state"); for (var i = 0; i < returnedArray.length; ++i) { state.append("" + returnedArray[i].Name + ""); } } }; $.ajax(options); }); }

但不填充? 我这样做的方式是你想怎么做?

谢谢。

 $("#state").change(function(){ //on-change code goes in here. //variable "this" references the state dropdown element }); 
 $(this).parent("select").attr("id");