<%@ page language="java" contentType="text/html; charset=gb2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Insert title here</title>
</head>
<body>
<form action="answer.jsp" method="post">
<table>
<tr>
<td>題目1:</td>
<td colSpan="4">詩人李白是中國歷史上那個朝代的人</td>
</tr>
<tr>
<td></td>
<td><input type="radio" name="num1" value="宋朝" checked="checked"/>宋朝</td>
<td><input type="radio" name="num1" value="唐朝"/>唐朝</td>
<td><input type="radio" name="num1" value="明朝"/>明朝</td>
<td><input type="radio" name="num1" value="元朝"/>元朝</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>題目2:</td>
<td colSpan="3">字母a後邊的字母為</td>
</tr>
<tr>
<td></td>
<td><input type="radio" name="num2" value="c" checked="checked"/>c</td>
<td><input type="radio" name="num2" value="b"/>b</td>
<td><input type="radio" name="num2" value="f"/>f</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>題目3:</td>
<td colSpan="3">字母f前邊的字母為</td>
</tr>
<tr>
<td></td>
<td><input type="radio" name="num3" value="e" checked="checked"/>e</td>
<td><input type="radio" name="num3" value="a"/>a</td>
<td><input type="radio" name="num3" value="m"/>m</td>
</tr>
<tr>
<td><input type="submit" value="確認"/></td>
</tr>
</table>
</form>
</body>
</html>
answer.jsp
<%
request.setCharacterEncoding("gb2312");//編碼轉換,訪止出現中文亂碼
int point=0;
String right="回答正確,加壹分";
String wrong="回答錯誤,不加分";
String isNum1Right;
String isNum2Right;
String isNum3Right;
if(request.getParameter("num1").equals("唐朝"))
{
isNum1Right=right;
point++;
}
else
{
isNum1Right=wrong;
}
if(request.getParameter("num2").equals("b"))
{
isNum2Right=right;
point++;
}
else
{
isNum2Right=wrong;
}
if(request.getParameter("num3").equals("e"))
{
isNum3Right=right;
point++;
}
else
{
isNum3Right=wrong;
}
%>
<%@ page language="java" contentType="text/html; charset=gb2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Insert title here</title>
</head>
<body>
<table>
<tr>
<td>題目1:詩人李白是中國歷史上那個朝代的人</td>
</tr>
<tr>
<td>妳的答案為:<%=request.getParameter("num1") %></td>
<td style="color:red">
<%=isNum1Right %>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>題目2:詩人李白是中國歷史上那個朝代的人</td>
</tr>
<tr>
<td>妳的答案為:<%=request.getParameter("num2") %></td>
<td style="color:red">
<%=isNum2Right %>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>題目3:詩人李白是中國歷史上那個朝代的人</td>
</tr>
<tr>
<td>妳的答案為:<%=request.getParameter("num3") %></td>
<td style="color:red">
<%=isNum3Right %>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td style="color:red">妳壹***加答對了<%=point %>道題.得到<%=point %>分</td>
</tr>
</table>
</body>
</html>