主题:一个页面有2个表单,这种情况怎么处理
<%@ page language="java" import="java.util.*" pageEncoding="gb2312" import="infoweb1.DBConnect"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
function select_onchange()
{
document.frm.action = "ServletArticle2";
document.frm.submit();
}
function del(id){
document.getElementById('cc').value=id;
document.form2.submit();//这里的XXXFROM改成你的form名
}
</SCRIPT>
<body>
<%
String strPageNo = request.getParameter("pageNo");
int pageNo ;
int totalPages = 0 , totalRecords = 0;
int pageSize = 15, strPos , strPos1 ;
try
{
DBConnect DBC2 = new DBConnect();
String str2 = "select count(id) as id from doc where sort = '党团工会'or sort = '员工园地'";
DBC2.excuteQuery(str2);
while(DBC2.next())
{
totalRecords = DBC2.getInt(1);
}
System.out.println(totalRecords);
totalPages = totalRecords % pageSize == 0 ? totalRecords / pageSize : totalRecords / pageSize + 1;
DBC2.close();
}
catch(Exception e)
{
e.printStackTrace();
}
if(strPageNo == null || strPageNo.equals(""))
{
pageNo = 1;
}
else
{
pageNo = Integer.parseInt(strPageNo);
if(pageNo <= 0)
pageNo = 1;
if(pageNo >= totalPages)
pageNo = totalPages;
}
strPos = (pageNo-1)*15;
// String str = "select id , title from article where name = '技术园地' order by time ";
//String str = "select top 3 id , title from article where name = '技术园地' order by time ";
// String str2 =SELECT top 页大小 * FROM article WHERE (ID NOT IN (SELECT TOP (页大小*(页数-1)) id FROM article order by id desc)) ORDER BY id DESC
// String str = "select top strPos id , title from article where name = '技术园地' and id not in(select top 3 id from article where name='技术园地' order by time) order by time ";
%>
<form name="frm" method="post" >
<table width="420" border="1" align="center">
<td> 文章分类:</td>
<td>
<select name="select" onchange="return select_onchange()">
<option>选择文章分类</option>
<option value="通知通告" >通知通告</option>
<option value="党团工会">党团工会</option>
<option value="员工园地">员工园地</option>
</select> </td>
</table>
</form>
<form name="form2" method="post" action="ServletArticle" >
<td><input type=hidden value="" name="cc" id="cc"></td>
<table width="420" border="1" align="center">
<tr>
<td width="180">文章标题</td>
<td width="150">发表时间</td>
<td width="79">删除</td>
</tr>
<%
String sort3 = (String)request.getAttribute("sort2");
if(sort3 != null)
{ String str = "select top 15 title, time , id from doc where sort = '"+sort3+"' and type = 1";
DBConnect DBC1 = new DBConnect();
DBC1.excuteQuery(str);
System.out.println(str);
try
{ while(DBC1.next())
{
String title2= DBC1.getString(1);
String date1 = DBC1.getString(2);
System.out.println(title2);
System.out.println(date1);
System.out.println(DBC1.getString(3));
//String date2 = (date1).substring(0, 10) ;
%>
<tr>
<td><%=title2%></td>
<td><%=date1 %></td>
<td><input type="button" name="删除" id="删除" value="删除" onclick="del('<%=DBC1.getString(3) %>')"/></td>
</tr>
<% }
}
catch(Exception e)
{
e.printStackTrace();
}
}%>
</table>
</form>
共<%=totalPages %>页 第<%=pageNo %>页 <a href="delete_article.jsp?pageNo=<%=pageNo-1 %>" >上一页</a> <a href="delete_article.jsp?pageNo=<%=pageNo+1 %>" >下一页</a>
</body>
</html>
我点删除之后,上面表单接收的参数为Null,所以select null ,怎么解决,我想要保持以前的参数不变
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
function select_onchange()
{
document.frm.action = "ServletArticle2";
document.frm.submit();
}
function del(id){
document.getElementById('cc').value=id;
document.form2.submit();//这里的XXXFROM改成你的form名
}
</SCRIPT>
<body>
<%
String strPageNo = request.getParameter("pageNo");
int pageNo ;
int totalPages = 0 , totalRecords = 0;
int pageSize = 15, strPos , strPos1 ;
try
{
DBConnect DBC2 = new DBConnect();
String str2 = "select count(id) as id from doc where sort = '党团工会'or sort = '员工园地'";
DBC2.excuteQuery(str2);
while(DBC2.next())
{
totalRecords = DBC2.getInt(1);
}
System.out.println(totalRecords);
totalPages = totalRecords % pageSize == 0 ? totalRecords / pageSize : totalRecords / pageSize + 1;
DBC2.close();
}
catch(Exception e)
{
e.printStackTrace();
}
if(strPageNo == null || strPageNo.equals(""))
{
pageNo = 1;
}
else
{
pageNo = Integer.parseInt(strPageNo);
if(pageNo <= 0)
pageNo = 1;
if(pageNo >= totalPages)
pageNo = totalPages;
}
strPos = (pageNo-1)*15;
// String str = "select id , title from article where name = '技术园地' order by time ";
//String str = "select top 3 id , title from article where name = '技术园地' order by time ";
// String str2 =SELECT top 页大小 * FROM article WHERE (ID NOT IN (SELECT TOP (页大小*(页数-1)) id FROM article order by id desc)) ORDER BY id DESC
// String str = "select top strPos id , title from article where name = '技术园地' and id not in(select top 3 id from article where name='技术园地' order by time) order by time ";
%>
<form name="frm" method="post" >
<table width="420" border="1" align="center">
<td> 文章分类:</td>
<td>
<select name="select" onchange="return select_onchange()">
<option>选择文章分类</option>
<option value="通知通告" >通知通告</option>
<option value="党团工会">党团工会</option>
<option value="员工园地">员工园地</option>
</select> </td>
</table>
</form>
<form name="form2" method="post" action="ServletArticle" >
<td><input type=hidden value="" name="cc" id="cc"></td>
<table width="420" border="1" align="center">
<tr>
<td width="180">文章标题</td>
<td width="150">发表时间</td>
<td width="79">删除</td>
</tr>
<%
String sort3 = (String)request.getAttribute("sort2");
if(sort3 != null)
{ String str = "select top 15 title, time , id from doc where sort = '"+sort3+"' and type = 1";
DBConnect DBC1 = new DBConnect();
DBC1.excuteQuery(str);
System.out.println(str);
try
{ while(DBC1.next())
{
String title2= DBC1.getString(1);
String date1 = DBC1.getString(2);
System.out.println(title2);
System.out.println(date1);
System.out.println(DBC1.getString(3));
//String date2 = (date1).substring(0, 10) ;
%>
<tr>
<td><%=title2%></td>
<td><%=date1 %></td>
<td><input type="button" name="删除" id="删除" value="删除" onclick="del('<%=DBC1.getString(3) %>')"/></td>
</tr>
<% }
}
catch(Exception e)
{
e.printStackTrace();
}
}%>
</table>
</form>
共<%=totalPages %>页 第<%=pageNo %>页 <a href="delete_article.jsp?pageNo=<%=pageNo-1 %>" >上一页</a> <a href="delete_article.jsp?pageNo=<%=pageNo+1 %>" >下一页</a>
</body>
</html>
我点删除之后,上面表单接收的参数为Null,所以select null ,怎么解决,我想要保持以前的参数不变