<html>
<head>
<title>
在线投票
</title>
<LINK href="style.css" rel=stylesheet>
</head>
<body>
<TABLE borderColor=#999999 cellSpacing=0 align=center cellPadding=0 width=100% border=0 bgcolor=#9999CC>
<TABLE borderColor=#999999 cellSpacing=0 align=center cellPadding=0 width=600 border=0 bgcolor=#9999CC>
<form action = thanks.jsp method=post>
<tr bgcolor=#999999 align=center><td>2007-11-26 12:21:17发布</td></tr>
<tr bgcolor=#999999><td>2.three</td></tr>
<td >
1
<input type=radio value="30" name="5" checked 1>
one
</td></tr>
<td >
2
<input type=radio value="31" name="5" >
two
</td></tr>
<td >
3
<input type=radio value="32" name="5" >
three
</td></tr>
<td >
4
<input type=radio value="33" name="5" >
four
</td></tr>
<td ><a href=result.jsp?questionid=5 target = _blank>three投票结果</a></td> </table><p>
<hr>
<div align=center>
<input class=buttonface type=submit value=提交 name=Submit>
<input class=buttonface type=reset value=重选 name=again>
</div><hr>
</form>
</table>
<TABLE borderColor=#999999 cellSpacing=0 align=center cellPadding=0 width=600 border=0 bgcolor=#9999CC>
<form action = thanks.jsp method=post>
<tr bgcolor=#999999 align=center><td>2007-11-26 12:21:38发布</td></tr>
<tr bgcolor=#999999><td>3.»î¶¯</td></tr>
<td >
1
<input type=radio value="34" name="6" checked 1>
»î¶¯1
</td></tr>
<td >
2
<input type=radio value="35" name="6" >
»î¶¯2
</td></tr>
<td >
3
<input type=radio value="36" name="6" >
»î¶¯3
</td></tr>
<td ><a href=result.jsp?questionid=6 target = _blank>»î¶¯投票结果</a></td> </table><p>
<hr>
<div align=center>
<input class=buttonface type=submit value=提交 name=Submit>
<input class=buttonface type=reset value=重选 name=again>
</div><hr>
</form>
</table>
<TABLE borderColor=#999999 cellSpacing=0 align=center cellPadding=0 width=600 border=0 bgcolor=#9999CC>
<form action = thanks.jsp method=post>
<tr bgcolor=#999999 align=center><td>2007-12-04 11:18:51发布</td></tr>
<tr bgcolor=#999999><td>4.who am I</td></tr>
<td >
1
<input type=radio value="85" name="10" checked 1>
tiger
</td></tr>
<td >
2
<input type=radio value="86" name="10" >
aking
</td></tr>
<td >
3
<input type=radio value="87" name="10" >
kimti
</td></tr>
<td >
4
<input type=radio value="88" name="10" >
hello
</td></tr>
<td ><a href=result.jsp?questionid=10 target = _blank>who am I投票结果</a></td> </table><p>
<hr>
<div align=center>
<input class=buttonface type=submit value=提交 name=Submit>
<input class=buttonface type=reset value=重选 name=again>
</div><hr>
</form>
</table>
<div align="center"><a href="admin/login.jsp">管理员进入</a></div><hr>
<div align="center"><a href="showresult.jsp">查看所有结果</a></div>
</body>
</html> JSP的原代码是<%@page contentType = "text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%@include file="opendata.jsp"%>
<html>
<head>
<title>
在线投票
</title>
<LINK href="style.css" rel=stylesheet>
</head>
<body>
<TABLE borderColor=#999999 cellSpacing=0 align=center cellPadding=0 width=100% border=0 bgcolor=#9999CC><%
sql = "SELECT Question,QuestionID,Date from questions where IsVisable = 1 ";
rs = smt.executeQuery(sql);
ResultSet _rs;
String question = null,item = null,_sql,Date=null;
Statement _smt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
int questionid = 0,itemid = 0;
int i=0,j; //题目及选项标号
while(rs.next()) {
i++;
question = rs.getString(1);
questionid= rs.getInt(2);
Date = rs.getString(3);
%>
<TABLE borderColor=#999999 cellSpacing=0 align=center cellPadding=0 width=600 border=0 bgcolor=#9999CC>
<form action = thanks.jsp method=post>
<tr bgcolor=#999999 align=center><td><%=Date%>发布</td></tr>
<tr bgcolor=#999999><td><%=i%>.<%=question%></td></tr>
<%
_sql = "SELECT Item,ItemID From Items Where QuestionID ="+questionid;
_rs = _smt.executeQuery(_sql);
j = 0;
while(_rs.next()) {
j++;
item = _rs.getString(1);
itemid = _rs.getInt(2);
//out.print("<tr>"+item);
%>
<td >
<%=j%>
<input type=radio value="<%=itemid%>" name="<%=questionid%>" <%if(j<2) {out.print(" checked "+j);}%>>
<%=item%>
</td></tr>
<%
//out.print("<td > "+j+"<input type=radio value="+itemid+" name="+questionid+" checked>"+item+"</td>");
//out.print("</tr>");
}
out.print("<td ><a href=result.jsp?questionid="+questionid+" target = _blank>"+question+"投票结果</a></td>");
out.print(" </table><p>");
%>
<hr>
<div align=center>
<input class=buttonface type=submit value=提交 name=Submit>
<input class=buttonface type=reset value=重选 name=again>
</div><hr>
</form>
</table>
<%}
%>
<div align="center"><a href="admin/login.jsp">管理员进入</a></div><hr>
<div align="center"><a href="showresult.jsp">查看所有结果</a></div></body>
</html>这是一个JSP的页面,其中有三个表单,我想在点击其中一个表单提交后可以成功插入到SQL上,下面是成功提交的代码<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>
<%@ page contentType = "text/html;charset=GBK" pageEncoding="GBK"%>
<%@include file="opendata.jsp"%>
<%@include file="convert.jsp"%>
<html>
<head>
<title>
感谢您的参与
</title>
<LINK href="style.css" rel=stylesheet>
</head>
<body>
<%
int questionid = 0;
int itemid = 0;
sql = "SELECT QuestionID from questions where IsVisable = 1 ";
rs = smt.executeQuery(sql);
String question = null,item = null,_sql;
Statement _smt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet _rs;
while(rs.next()){
questionid = rs.getInt(1);
itemid = Integer.parseInt(request.getParameter(String.valueOf(questionid)));
_sql = "update Items set ItemCount = ItemCount + 1 Where ItemID ="+itemid;
_smt.executeUpdate(_sql);
}
%>
<center>
感谢您的参与!<p>
<div align="center"><a href="showresult.jsp">查看投票结果</a></div>
<p>
<div align="center"><a href="Javascript:window.close();">关闭窗口</a></div>
</center>
</body>
</html>大侠们看看我的那里错了...我在点击提交后tomcat出现的错是.
HTTP Status 500 -type Exception reportmessagedescription The server encountered an internal error () that prevented it from fulfilling this request.exceptionorg.apache.jasper.JasperException: Exception in JSP: /thanks.jsp:2926: questionid = rs.getInt(1);
27: //itemid = rs.getInt(questionid);
28: //questionid =Integer.parseInt(request.getParameter("questionid"));
29: itemid = Integer.parseInt(request.getParameter(String.valueOf(questionid)));
30: //itemid = Integer.parseInt(questionid);
31:
32: // itemid = rs.getInt(1);小弟急呀......
<head>
<title>
在线投票
</title>
<LINK href="style.css" rel=stylesheet>
</head>
<body>
<TABLE borderColor=#999999 cellSpacing=0 align=center cellPadding=0 width=100% border=0 bgcolor=#9999CC>
<TABLE borderColor=#999999 cellSpacing=0 align=center cellPadding=0 width=600 border=0 bgcolor=#9999CC>
<form action = thanks.jsp method=post>
<tr bgcolor=#999999 align=center><td>2007-11-26 12:21:17发布</td></tr>
<tr bgcolor=#999999><td>2.three</td></tr>
<td >
1
<input type=radio value="30" name="5" checked 1>
one
</td></tr>
<td >
2
<input type=radio value="31" name="5" >
two
</td></tr>
<td >
3
<input type=radio value="32" name="5" >
three
</td></tr>
<td >
4
<input type=radio value="33" name="5" >
four
</td></tr>
<td ><a href=result.jsp?questionid=5 target = _blank>three投票结果</a></td> </table><p>
<hr>
<div align=center>
<input class=buttonface type=submit value=提交 name=Submit>
<input class=buttonface type=reset value=重选 name=again>
</div><hr>
</form>
</table>
<TABLE borderColor=#999999 cellSpacing=0 align=center cellPadding=0 width=600 border=0 bgcolor=#9999CC>
<form action = thanks.jsp method=post>
<tr bgcolor=#999999 align=center><td>2007-11-26 12:21:38发布</td></tr>
<tr bgcolor=#999999><td>3.»î¶¯</td></tr>
<td >
1
<input type=radio value="34" name="6" checked 1>
»î¶¯1
</td></tr>
<td >
2
<input type=radio value="35" name="6" >
»î¶¯2
</td></tr>
<td >
3
<input type=radio value="36" name="6" >
»î¶¯3
</td></tr>
<td ><a href=result.jsp?questionid=6 target = _blank>»î¶¯投票结果</a></td> </table><p>
<hr>
<div align=center>
<input class=buttonface type=submit value=提交 name=Submit>
<input class=buttonface type=reset value=重选 name=again>
</div><hr>
</form>
</table>
<TABLE borderColor=#999999 cellSpacing=0 align=center cellPadding=0 width=600 border=0 bgcolor=#9999CC>
<form action = thanks.jsp method=post>
<tr bgcolor=#999999 align=center><td>2007-12-04 11:18:51发布</td></tr>
<tr bgcolor=#999999><td>4.who am I</td></tr>
<td >
1
<input type=radio value="85" name="10" checked 1>
tiger
</td></tr>
<td >
2
<input type=radio value="86" name="10" >
aking
</td></tr>
<td >
3
<input type=radio value="87" name="10" >
kimti
</td></tr>
<td >
4
<input type=radio value="88" name="10" >
hello
</td></tr>
<td ><a href=result.jsp?questionid=10 target = _blank>who am I投票结果</a></td> </table><p>
<hr>
<div align=center>
<input class=buttonface type=submit value=提交 name=Submit>
<input class=buttonface type=reset value=重选 name=again>
</div><hr>
</form>
</table>
<div align="center"><a href="admin/login.jsp">管理员进入</a></div><hr>
<div align="center"><a href="showresult.jsp">查看所有结果</a></div>
</body>
</html> JSP的原代码是<%@page contentType = "text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%@include file="opendata.jsp"%>
<html>
<head>
<title>
在线投票
</title>
<LINK href="style.css" rel=stylesheet>
</head>
<body>
<TABLE borderColor=#999999 cellSpacing=0 align=center cellPadding=0 width=100% border=0 bgcolor=#9999CC><%
sql = "SELECT Question,QuestionID,Date from questions where IsVisable = 1 ";
rs = smt.executeQuery(sql);
ResultSet _rs;
String question = null,item = null,_sql,Date=null;
Statement _smt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
int questionid = 0,itemid = 0;
int i=0,j; //题目及选项标号
while(rs.next()) {
i++;
question = rs.getString(1);
questionid= rs.getInt(2);
Date = rs.getString(3);
%>
<TABLE borderColor=#999999 cellSpacing=0 align=center cellPadding=0 width=600 border=0 bgcolor=#9999CC>
<form action = thanks.jsp method=post>
<tr bgcolor=#999999 align=center><td><%=Date%>发布</td></tr>
<tr bgcolor=#999999><td><%=i%>.<%=question%></td></tr>
<%
_sql = "SELECT Item,ItemID From Items Where QuestionID ="+questionid;
_rs = _smt.executeQuery(_sql);
j = 0;
while(_rs.next()) {
j++;
item = _rs.getString(1);
itemid = _rs.getInt(2);
//out.print("<tr>"+item);
%>
<td >
<%=j%>
<input type=radio value="<%=itemid%>" name="<%=questionid%>" <%if(j<2) {out.print(" checked "+j);}%>>
<%=item%>
</td></tr>
<%
//out.print("<td > "+j+"<input type=radio value="+itemid+" name="+questionid+" checked>"+item+"</td>");
//out.print("</tr>");
}
out.print("<td ><a href=result.jsp?questionid="+questionid+" target = _blank>"+question+"投票结果</a></td>");
out.print(" </table><p>");
%>
<hr>
<div align=center>
<input class=buttonface type=submit value=提交 name=Submit>
<input class=buttonface type=reset value=重选 name=again>
</div><hr>
</form>
</table>
<%}
%>
<div align="center"><a href="admin/login.jsp">管理员进入</a></div><hr>
<div align="center"><a href="showresult.jsp">查看所有结果</a></div></body>
</html>这是一个JSP的页面,其中有三个表单,我想在点击其中一个表单提交后可以成功插入到SQL上,下面是成功提交的代码<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>
<%@ page contentType = "text/html;charset=GBK" pageEncoding="GBK"%>
<%@include file="opendata.jsp"%>
<%@include file="convert.jsp"%>
<html>
<head>
<title>
感谢您的参与
</title>
<LINK href="style.css" rel=stylesheet>
</head>
<body>
<%
int questionid = 0;
int itemid = 0;
sql = "SELECT QuestionID from questions where IsVisable = 1 ";
rs = smt.executeQuery(sql);
String question = null,item = null,_sql;
Statement _smt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet _rs;
while(rs.next()){
questionid = rs.getInt(1);
itemid = Integer.parseInt(request.getParameter(String.valueOf(questionid)));
_sql = "update Items set ItemCount = ItemCount + 1 Where ItemID ="+itemid;
_smt.executeUpdate(_sql);
}
%>
<center>
感谢您的参与!<p>
<div align="center"><a href="showresult.jsp">查看投票结果</a></div>
<p>
<div align="center"><a href="Javascript:window.close();">关闭窗口</a></div>
</center>
</body>
</html>大侠们看看我的那里错了...我在点击提交后tomcat出现的错是.
HTTP Status 500 -type Exception reportmessagedescription The server encountered an internal error () that prevented it from fulfilling this request.exceptionorg.apache.jasper.JasperException: Exception in JSP: /thanks.jsp:2926: questionid = rs.getInt(1);
27: //itemid = rs.getInt(questionid);
28: //questionid =Integer.parseInt(request.getParameter("questionid"));
29: itemid = Integer.parseInt(request.getParameter(String.valueOf(questionid)));
30: //itemid = Integer.parseInt(questionid);
31:
32: // itemid = rs.getInt(1);小弟急呀......
比如:
function submit(){
formName.action = thanks.jsp
formName.submit
}
<input class=buttonface type=button value=提交 name=Submit onclick="submit()">
.......
cangbai
等 级:
发表于:2007-12-13 13:39:103楼 得分:0
把3个提交放在一个form里面,提交按钮都改成button,每个button写一个onclick时间,当点击时就提交给相应的.jsp
比如:
function submit(){
formName.action = thanks.jsp
formName.submit
}
<input class=buttonface type=button value=提交 name=Submit onclick="submit()">
.......
还是不行呀.....
function submitForm1(){
formName1.action = "thanks.jsp"
formName1.submit();
}
<input class=buttonface type=button value=提交 name=Submit onclick="submitForm1()">
....... 这里的formName是要在表单里起的名子的,而且几个名子要不同的,例如:
<form name="formName1" method="post">
<tr bgcolor=#999999 align=center><td>2007-11-26 12:21:17发布</td></tr>
<tr bgcolor=#999999><td>2.three</td></tr>
<td >
...function submitForm1(){
formName1.action = "thanks.jsp"
formName1.submit();
}
<input class=buttonface type=button value="提交" name=Submit onclick="submitForm1()"> ........
<form name="formName2" action ="thanks.jsp" method="post">
<tr bgcolor=#999999 align=center><td>2007-11-26 12:21:17发布</td></tr>
<tr bgcolor=#999999><td>2.three</td></tr>
<td > ...function submitForm2(){
formName2.action = "thanks.jsp"
formName2.submit();
}
<input class=buttonface type=button value="提交" name=Submit onclick="submitForm2()">
........每个表单都要这么写的...2.还有一点,就是像'<a href='、'action='、'radio='等后面都尽量用引号或双引号引起来!
<script>
function dosubmit(a)
{
if(a==1)
{
f1.action="1.jsp"
f1.submit();
}
if(a==2)
{
f2.action="2.jsp"
f2.submit();
}
if(a==3)
{
f3.action="3.jsp"
f3.submit();
}
}</script><form name="f1">
<input type="button" onclick="dosubmit(1)">
</form>
<form name="f2">
<input type="button" onclick="dosubmit(2)">
</form>
<form name="f3">
<input type="button" onclick="dosubmit(3)">
</form>