如题
------最佳解决方案--------------------
jsp代码:
<tr height="33">
<td>省份:
<select id="province" name="profile.province" onChange = "loadCity(this.value);">
<option value="0">请选择省份名</option>
<s:iterator value="provinces">
<option value="<s:property value="name" />" <s:if test="name==profile.province">selected="selected"</s:if> ><s:property value="name" /></option>
</s:iterator>
</select>
</td>
<td>城市:
<select id="city" name="profile.city">
<option value="0">请选择城市名</option>
</select>
</td>
</tr>
js:
function loadCity(provincename){
var cityDom = "<option>请选择城市名</option>";
$.ajax({
type:"post",
data:"provincename=" + provincename,
dataType:"json",
async:false,
url: "view-personal-entry!getCity.action",
success:function(data){
for(var i=0;i<data.length;i++) {
cityDom += '<option value="'+data[i]+'">'+data[i]+'</option>'
}
$("#city").html(cityDom);
}
});
}