以下是一个在线考试页面,我已经用AJAX实现了点击“提交此题”页面不刷新,并且更新了数据,但我想点击了“提交此题”之后该题的字体颜色变成灰色,并且把四个checkBox设为不可编辑,我应该怎么写? <%@ page language="java" import="java.util.*,tuanWeiSuZhiTuoZhan.ActionForm.*" pageEncoding="GB18030"%>
<%
String path = request.getContextPath(); //String xueHao = (String)session.getAttribute("xueHao");
String xueShengXingMing = (String) session
.getAttribute("xueShengXingMing");//学生姓名
ArrayList shiJuanList = (ArrayList) session
.getAttribute("shiJuanList");//试卷信息
%><html>
<head>
<title>测试题</title>
<script type="text/javascript" language="javascript">
/***********************ajax局部请求******************************/
var http_request = false;
function createRequest(url) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla浏览器
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml'); //设置MIME类别
}
} else if (window.ActiveXObject) { // IE浏览器
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert("不能创建XMLHttpRequest对象实例!");
return false;
}
http_request.onreadystatechange = getResult; //调用返回结果处理函数
http_request.open('post', url, true);//此处调用getResult()
http_request.send(null);
}
function getResult() {
if (http_request.readyState == 4) { // 判断请求状态
if (http_request.status == 200) { // 请求成功,开始处理返回结果
} else { //请求页面有错误
alert("您所请求的页面有错误!");
}
}
}
/*****************************Ajax传递参数到Action****************************/
function tiJiao(SJzdbm,form) {
var A = 0;
var B = 0;
var C = 0;
var D = 0;
if(form("A").checked){
A = 1;
}
if(form("B").checked){
B = 1;
}
if(form("C").checked){
C = 1;
}
if(form("D").checked){
D = 1;
}
createRequest("<%=path%>/login.do?method=sztz_xsks_tiJiaoDaAn&SJzdbm="+SJzdbm+"&A="+A+"&B="+B+"&C="+C+"&D="+D);
}
</script>
</head>
<body>
<center>
<table width="800" border="0" cellspacing="0" cellpadding="0">
<tr><td align="center"><span style="font-size:18pt">测试题</span></td></tr>
<tr><td>您好,<%=xueShengXingMing%>,祝你考试愉快!</td></tr>
</table>
<%
if (shiJuanList == null || shiJuanList.size() == 0) {
%>
<table height="600" width="800" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><span style="font-size:18pt">试题读取失败!请与管理员联系!</span></td>
</tr>
</table>
<%
} else {
%>
<!-- 迭代每一道试题 -->
<%
for (int i = 0; i < shiJuanList.size(); i++) {
SZTZ_DengLu_ActionForm shiJuanForm = (SZTZ_DengLu_ActionForm) shiJuanList
.get(i);
String style = "black";
String disabled = "";
if (shiJuanForm.isKaoShiTiJiaoFou()) {//判断该题是否已经被提交
style = "gray";//提交过的题目,字体设为灰色
disabled = "disabled";//禁用checkBox
}
boolean A = shiJuanForm.isKaoShiA1();//学生选项A
boolean B = shiJuanForm.isKaoShiB1();//学生选项B
boolean C = shiJuanForm.isKaoShiC1();//学生选项C
boolean D = shiJuanForm.isKaoShiD1();//学生选项D
%>
<form action="" method="post" name="kaoShiForm<%=i+1 %>">
<table width="800" border="0" cellspacing="0" cellpadding="0" style="color:<%=style%>">
<tr>
<td width="3%"><%=i + 1%>.</td>
<td><%=shiJuanForm.getKaoShiTMMC()%></td>
<td width="10%" align="right" valign="top"><input type="button" <%=disabled%> value="提交此题" onClick="tiJiao(<%=shiJuanForm.getKaoShiSJzdbm() %>,this.form)"/></td>
</tr>
<tr>
<td><input type="checkbox" name="A" id="A" <%=disabled%> <%if(A){%>checked<%} %>/></td>
<td>A.<%=shiJuanForm.getKaoShiAmc()%></td>
<td></td>
</tr>
<tr>
<td><input type="checkbox" name="B" id="B" <%=disabled%> <%if(B){%>checked<%} %>/></td>
<td>B.<%=shiJuanForm.getKaoShiBmc()%></td>
<td></td>
</tr>
<tr>
<td><input type="checkbox" name="C" id="C" <%=disabled%> <%if(C){%>checked<%} %>/></td>
<td>C.<%=shiJuanForm.getKaoShiCmc()%></td>
<td></td>
</tr>
<tr>
<td><input type="checkbox" name="D" id="D" <%=disabled%> <%if(D){%>checked<%} %>/></td>
<td>D.<%=shiJuanForm.getKaoShiDmc()%></td>
<td></td>
</tr>
</table>
</form>
<%
}
%>
<!-- 提交试卷 -->
<form name="wanChengForm" action="" method="post">
<input type="hidden" name="method" value="sztz_xsks_tiJiaoShiJuan"/>
<table width="800" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><input type="submit" value="我已完成" onclick="return window.confirm('确定你的试卷完成并且提交吗?')"/></td>
<td align="center"><input type="button" value="下次再做" onclick="javascript:history.back(-1)"/></td>
</tr>
</table>
</form>
<%
}
%>
</center>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货