Issuer:</label></td>
<td colspan="4"><select class="SelectWideWidth" name="prov" id="selIssuerProvince" οnchange="porvSelect(-1)">
</select>
<select class="SelectWideWidth" name="issuerId" id="selissuer" style="margin-left:30px; width:270px">
</select></td>
$.ajax({
type : "POST", // 提交方式
url : "ajax/loadIssuerProvince.action?id="+$("#provId").val(), // 提交的页面
dataType : "json", // 类型
success : function(result) {
$("#selIssuerProvince option").each(function() {
$(this).remove(); // 移除原有项
});
$("<option value=''>----Blank----</option>").appendTo( "#selIssuerProvince"); // 添加一个默认项
$(result).appendTo("#selIssuerProvince");
}
});
function porvSelect(strid) {
var code = $("#selIssuerProvince").val();
if(code==null){
code=$("#provId").val();
}
var id = strid;
$.ajax({
type : "POST", // 提交方式
url : "ajax/loadIssuer?code="+code+"&id="+id, // 提交的页面
dataType : "json", // 类型
success : function(result) {
$("#selissuer option").each(function() {
$(this).remove(); // 移除原有项
});
$("<option value=''>----Blank----</option>").appendTo("#selissuer"); // 添加一个默认项
$(result).appendTo("#selissuer");
}
});
}
@Action(value = "loadIssuerProvince", results = { @Result(type = "json", params = {
"contentType", "text/html", "root", "result" }) })
public String loadIssuerProvince() {
String id = request.getParameter("id");
StringBuffer str = new StringBuffer();
List<Map<String, Object>> list = pservice.getIssuerProvices();
for (int i = 0; i < list.size(); i++) {
str.append("<option value='");
str.append(list.get(i).get("PROVINCE_ID"));
str.append("' ");
if (list.get(i).get("PROVINCE_ID").toString().equals(id)) {
str.append(" selected='selected'");
}
str.append("");
str.append(">");
// str.append("#");
str.append(list.get(i).get("name"));
// str.append("#");
str.append("</option>");
}
result = str + "";
return SUCCESS;
}
@Action(value = "loadIssuer", results = { @Result(type = "json", params = {
"contentType", "text/html", "root", "result" }// root<会带外引号>
// includeProperties Result不带字符引号
// excludeProperties 返回所有的属性
) })
public String loadIssuer() {
String code = request.getParameter("code");
int id = -1;
try {
id = Integer.parseInt(request.getParameter("id"));
} catch (Exception e) {
// TODO: handle exception
}
StringBuffer str = new StringBuffer();
List<IsicIssuer> list = issuerService.findIsicIssuerList(code, null);
for (int i = 0; i < list.size(); i++) {
str.append("<option value='");
str.append(list.get(i).getIssuerId());
str.append("' ");
if (list.get(i).getIssuerId() == id) {
str.append("selected='selected' ");
}
str.append(">");
// str.append("#");
str.append(list.get(i).getIssuer_name());
// str.append("#");
str.append("</option>");
}
result = str + "";
return SUCCESS;
}