<script src="<%=request.getContextPath()%>/creditapp/js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
function appExamSubmit(f) {
var score_list = "";
var appNo = document.getElementById("app_no").value;
$("input[type=checkbox]").each(function() {//遍历checkbox,将选择情况连接成String score_list 。
parm_code = $(this).attr("id");
score_list += parm_code;
score_list += ":";
if ($(this).attr("checked") == true) {
score_list += "Y";
} else {
score_list += "N";
}
score_list += "&";
});
$.post("ApproveForLoanAction_saveAppExams.action", {//接收的Action
score_list : score_list,//传递的参数
appNo : appNo,
rdm : Math.random()
}, function(data) {
if ("success" == $.trim(data)) {
sAlert("保存成功!");
} else {
sAert("通讯过程中出现错误,请与管理员联系。");
}
});
}
</script>
以上为jsp页面代码。
下面为Action中的代码:
/*保存指标的确认信息*/
public void saveAppExams() throws Exception {
AppExamList appexamlist = new AppExamList();
HttpServletRequest req = this.getHttpRequest();
PrintWriter out = null;
String score_list = req.getParameter("score_list");
try {
out = this.getHttpResponse().getWriter();
} catch (IOException e) {
e.printStackTrace();
}
appexamlist.setApp_no(appNo);
appexamlist.setTrace_no(appNo);
appexamlist.setScore_list(score_list);
try{
appexamlistbo.insertOrUpdate(appexamlist);
out.write("success");
}catch(Exception e){
out.write("error");
throw(e);
}finally{
out.flush();
out.close();
}
}
注意事项:
1.别忘了引入jQuery。
2.没有了。