?? questionchange.jsp
字號:
<%@ page contentType="text/html;charset=GBK" %>
<%@ page language="java" import="java.sql.*"%>
<%@ page import="java.lang.Math.*" %>
<%@ page import="java.util.*" %>
<jsp:useBean id="conn" scope="page" class="test.ConnOracle"/>
<%@ include file="/public/checkvalidadmin.jsp"%>
<%@ include file="/public/checkvalidadmin8.jsp"%>
<%!
String id = "";
String sql = "";
ResultSet rs = null;
ResultSet rs1 = null;
int tmpquestionid ;
String currpage = "1"; // 在連續的幾個頁面中,一直保存當前頁面,便于用戶操作
int tmp_questionid;
String tmp_qname;
String tmp_choice1;
String tmp_choice2;
String tmp_choice3;
String tmp_choice4;
int tmp_selectid;
String tmp_classid;
String tmp_answer;
String tmp1_classname;
String tmp1_classid;
%>
<html>
<head>
<title>題目信息修改</title>
<link rel="stylesheet" href="../public/style.css">
<script language="javascript">
// 函數mycheck()的作用是驗證用戶修改題庫信息的正確性
function mycheck() {
var tmp_selectid = document.myform.selectid.selectedIndex;
var tmp_answer = document.myform.answer.value;
var tmp_choice1 = document.myform.choice1.value;
var tmp_choice2 = document.myform.choice2.value;
var tmp_choice3 = document.myform.choice3.value;
var tmp_choice4 = document.myform.choice4.value;
if(document.myform.qname.value == "") {
alert("請輸入題目!");
return;
}
if(tmp_choice1.length==0 || tmp_choice2.length==0 || tmp_choice3.length==0 || tmp_choice4.length==0 ) {
alert("請輸入各個選項!");
return;
}
if(tmp_answer.length == 0) {
alert("請選擇題目答案!");
return;
}
if(tmp_selectid==0 && tmp_answer.length>1) {
alert("單選題的答案應該唯一!");
return;
}
if(tmp_answer.length > 4) {
alert("多選題最多4個答案!");
return;
}
document.myform.submit();
}
</script>
</head>
<%
currpage = request.getParameter("Page");
sql = "select * from test_classinfo";
try {
rs1 = conn.executeQuery( sql );
}catch(Exception e) {
out.println("訪問課程信息數據出錯!");
return;
}
if(!rs1.next()) {
out.println("系統數據庫中無課程信息數據!");
return;
}
id = request.getParameter("id");
sql = "SELECT * from test_question_lib where questionid=" + id;
try {
rs = conn.executeQuery( sql );
}catch(Exception ee) {
out.println("訪問數據庫錯誤!");
return;
}
if(!rs.next()) {
out.println("錯誤的ID號");
return;
}else {
tmp_questionid = rs.getInt("questionid");
tmp_selectid = rs.getInt("selectid");
tmp_classid = rs.getString("classid");
tmp_qname = rs.getString("qname");
tmp_choice1 = rs.getString("choice1");
tmp_choice2 = rs.getString("choice2");
tmp_choice3 = rs.getString("choice3");
tmp_choice4 = rs.getString("choice4");
tmp_answer = rs.getString("answer");
tmp1_classid = rs1.getString("classid");
tmp1_classname = rs1.getString("classname");
%>
<center>
<form name="myform" action="questionsavemodify.jsp" method="post">
<input type="hidden" name="Page" value="<%=currpage%>">
<table width="90%" HEIGHT=100% border="1" cellspacing="0" cellpadding="0" bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr bgcolor="#FAD185">
<%
tmpquestionid = tmp_questionid;
%>
<td colspan=6 height=20 align=center><b>題目信息修改==>題目編號:<%=tmpquestionid%></b></td>
<input type="hidden" name="questionid" value="<%=tmpquestionid%>">
</tr>
<tr>
<td colspan=6 valign=top>
<textarea name="qname" rows=20 cols=150><%=tmp_qname%></textarea></td>
</tr>
<tr>
<td width=10%>選項A</td>
<td colspan=5><textarea name="choice1" rows=2 cols=135><%=tmp_choice1%></textarea></td>
</tr>
<tr>
<td>選項B</td>
<td colspan=5><textarea name="choice2" rows=2 cols=135><%=tmp_choice2%></textarea></td>
</tr>
<tr>
<td>選項C</td>
<td colspan=5><textarea name="choice3" rows=2 cols=135><%=tmp_choice3%></textarea></td>
</tr>
<tr>
<td>選項D</td>
<td colspan=5><textarea name="choice4" rows=2 cols=135><%=tmp_choice4%></textarea></td>
</tr>
<tr>
<td>題目類別</td>
<td>
<!--以下這一段出現問題:java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]無效的描述符索引-->
<select name="selectid">
<%
int tmpselectid = tmp_selectid;
if(tmpselectid==1) {
out.println("<option value=1 selected>單選題</option>");
out.println("<option value=2>多選題</option>");
}else {
out.println("<option value=1>單選題</option>");
out.println("<option value=2 selected>多選題</option>");
}
%>
</select>
</td>
<td>對應班級</td>
<td>
<select name="classid">
<%
String currClassId = tmp_classid;
do{
String classname = tmp1_classname;
String classid = tmp1_classid;
%>
<option value=<%=classid%> <%if(classid.equals(currClassId)) out.println("selected");%> ><%=classname%> </option>
<%
}while(rs1.next());
%>
</select>
<!--以上這一段出現問題 -->
</td>
<td>答案</td>
<td><input type=text title="輸入答案時請按照字母次序進行輸入,例如:AB / ABD" name=answer value=<%=tmp_answer%>></td>
</tr>
<tr>
<td align=center colspan=6>
<input type="button" value="保存所做修改" onclick="mycheck()">
<input type="button" value="返回上一頁面" onclick=javascript:history.back()>
</td>
</tr>
</table>
<%
}
%>
</form>
</center>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -