好的,谢谢大家
代码如下:
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@include file="connect.inc"%>
<%
//判断是不是管理员
String manager=(String)session.getAttribute("manager");
if(manager==null || !manager.equals("true")){
response.sendRedirect("login.jsp");
}
%>
<%
String strSql;
String subject="",answer="";
String optionA="",optionB="",optionC="",optionD="";
String note="";
String id;
String strMsg="此ID不存在!";
int chapter=0,passage=0;
boolean isError=true; //是否出错
%>
<%
request.setCharacterEncoding("utf-8");
if(request.getParameter("id")!=null)
//提交数据
{
id=request.getParameter("id");
strSql="select * from tb_questions where id="+id;
//out.print(strSql);
rs=st.executeQuery(strSql);
if (rs.next())
{
subject=rs.getString("subject");
chapter=rs.getInt("chapter");
optionA=rs.getString("optionA");
optionB=rs.getString("optionB");
optionC=rs.getString("optionC");
optionD=rs.getString("optionD");
answer=rs.getString("answer");
note=rs.getString("note");
passage=rs.getInt("passage");
}else{
out.print("<script>alert('"+strMsg+"');window.history.back();</script>");
}
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>试题详细信息</title>
<style type="text/css">
<!--
.STYLE5 {color: #0000FF}
body {
margin-top: 0px;
margin-left: 0px;
}
html {overflow-x:hidden;}
-->
</style>
</head>
<body style="overflow-x:hidden">
<form action=""
method="post" name="form1" id="form1" onsubmit="return dataCheck()">
<table width="780" height="380" border="1" align="left" cellpadding="2" cellspacing="0" bordercolor="#9999CC" bgcolor="#f7f7f7">
<tr>
<td width="140" align="right" valign="middle" bordercolor="#FFFFFF" bgcolor="#F7F7F7"><span class="STYLE5"> 题目:</span></td>
<td width="500" height="30" align="left" valign="middle" bordercolor="#FFFFFF" bgcolor="#F7F7F7"><input name="subject" type="text" id="subject" value=<%=subject%> size="60" maxlength="150" /></td>
</tr>
<tr>
<td width="140" align="right" valign="middle" bordercolor="#FFFFFF" bgcolor="#F7F7F7"><span class="STYLE5"> 章节:</span></td>
<td width="500" height="20" align="left" valign="top" bordercolor="#FFFFFF" bgcolor="#F7F7F7"><select name="chapter" id="chapter">
<%
for(int i=1;i<=6;i++)
if (chapter==i)
out.print("<option selected='selected' value="+i+">"+i+"</option>");
else
out.print("<option value="+i+">"+i+"</option>");
%>
</select>
</td>
</tr>
<tr>
<td width="140" height="40" align="right" valign="top" bordercolor="#FFFFFF" bgcolor="#F7F7F7"><span class="STYLE5"> 选项:</span></td>
<td width="500" valign="top" bordercolor="#FFFFFF" bgcolor="#F7F7F7" > A)
<input name="optionA" type="text" id="optionA" value=<%=optionA%> size="70" />
<br />
B)
<input name="optionB" type="text" id="optionB" value=<%=optionB%> size="70" />
<br />
C)
<input name="optionC" type="text" id="optionC" value=<%=optionC%> size="70" />
<br />
D)
<input name="optionD" type="text" id="optionD" value=<%=optionD%> size="70" />
</td>
</tr>
<tr>
<td width="140" height="37" align="right" valign="top" bordercolor="#FFFFFF" bgcolor="#F7F7F7"><span class="STYLE5"> 答案:</span></td>
<td width="500" valign="top" bordercolor="#FFFFFF" bgcolor="#F7F7F7" ><select name="answer" id="answer">
<%
for(char c='A';c<='D';c++)
if (answer.equals(c+""))
out.print("<option selected='selected' value='"+c+"' >"+c+"</option>");
else
out.print("<option value='"+c+"' >"+c+"</option>");
%>
</select></td>
</tr>
<tr>
<td width="140" align="right" valign="top" bordercolor="#FFFFFF" bgcolor="#F7F7F7"><span class="STYLE5"> 备注:<br />
</span></td>
<td width="500" height="30" bordercolor="#FFFFFF" bgcolor="#F7F7F7"><textarea name="note" cols="60" rows="3" id="note"><%=note%>
</textarea></td>
</tr>
<tr>
<td width="140" height="32" align="right" valign="middle" bordercolor="#FFFFFF" bgcolor="#F7F7F7"><span class="STYLE5">Passage:</span></td>
<td width="500" bordercolor="#FFFFFF" bgcolor="#F7F7F7"><label>
<input name="passage" type="text" id="passage" value=<%=passage%> size="10" maxlength="3" />
</label></td>
</tr>
<tr>
<td width="140" height="44" bordercolor="#FFFFFF" bgcolor="#F7F7F7"> </td>
<td width="500" align="center" valign="middle" bordercolor="#FFFFFF" bgcolor="#F7F7F7">
<input type="submit" value="提交" name="button1" />
<input name="button3" type="reset" id="button3" value="重
置" /></td>
</tr>
</table>
</form>
</body>
</html>