主题:求把搜索和显示的分开!asp+access
共分三个页面,一个主页表单提交“书名.作者、出版社”等条件查询!代码如下:最好辅助说明!<!--#include file="conn.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="inc/config.asp"-->
<HTML>
<HEAD><script type="text/javascript">function DDtoDay(inputDate)
{
var dateString = new Array('','st','nd','rd','th','th','th','th','th','th','th','th','th','th','th','th','th','th','th','th','th','st','nd','rd','th','th','th','th','th','th','th','st');
returnDate = '';
tempDate = parseInt(inputDate);
if (tempDate >= 1 && tempDate <= 31)
{
returnDate = inputDate + dateString[tempDate];
}
return returnDate;
}</script>
<TITLE><%=fypSysTitle & " " & currentAspFileName()%></TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<LINK HREF="css/css.css" REL="stylesheet" TYPE="text/css">
<SCRIPT LANGUAGE="javascript" SRC="js/js.js"></SCRIPT>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
left:25px;
top:96px;
width:423px;
height:55px;
z-index:1;
}
#apDiv2 {
position:absolute;
left:122px;
top:266px;
width:860px;
height:133px;
z-index:2;
}
-->
</style>
</head>
<script type="text/javascript" src="flashfloat.js"></script>
<script type="text/javascript" src="flashobject.js"></script>
<BODY LEFTMARGIN="0" TOPMARGIN="0">
<FORM ACTION="<%=currentAspFileFullName()%>" METHOD="post" NAME="<%=currentAspFileName()%>_Form" ID="<%=currentAspFileName()%>_Form" STYLE="display:inline" onsubmit="return checkForm(this)">
<div id="apDiv1">
<div id="macro-style_id" >daohang</div>
<script type="text/javascript">
var fo = new FlashObject("jw1.swf", "macro-style", "400", "65", "6", "#FFFFFF");
fo.addParam("menu","false");
fo.addParam("quality","best");
fo.addParam("salign","LT");
fo.addParam("scale","noscale");
fo.addParam("wmode","transparent");
fo.write("macro-style_id");
if (navigator.appName.indexOf("Microsoft")!= -1) {
document.floater.style.position="absolute";
document.floater.style.zIndex="10";
document.floater.style.left="0px";
document.floater.style.top="0px";
}else{
document.getElementById('floater').style.position="absolute";
document.getElementById('floater').style.zIndex="10";
document.getElementById('floater').style.left="0px";
document.getElementById('floater').style.top="0px";
}</script>
</div>
<p><img src="images/index.jpg" width="950" height="195"></p>
<TABLE WIDTH="" BORDER="0" ALIGN="left" CELLPADDING="5" CELLSPACING="1" CLASS="tableStyleSolidLine">
<tr>
<td width="39" nowrap>[书名]</td>
<td width="0"></td>
<td width="153"><input type='text' name='ctrl_ShuMing' id='ctrl_ShuMing' maxlength='255' value='<%=Request.Form("ctrl_ShuMing")%>' style='width:100%' class='textBox'></td>
<td width="33">[作者]</td>
<td width="190"><input type='text' name='ctrl_ZuoZhe' id='ctrl_ZuoZhe' maxlength='255' value='<%=Request.Form("ctrl_ZuoZhe")%>' style='width:100%' class='textBox'></td>
<td width="51">[出版社]</td>
<td width="156"><input type='text' name='ctrl_ChuBanShe' id='ctrl_ChuBanShe' maxlength='255' value='<%=Request.Form("ctrl_ChuBanShe")%>' style='width:100%' class='textBox'></td>
<td width="121"><INPUT TYPE="submit" NAME="Submit" VALUE="查找">
<INPUT TYPE="reset" NAME="Reset" VALUE="重置"></td>
</tr>
</TABLE>
<p> </p>
<p> </p>
<p> </p>
<p>
<%
Dim errMessage
errMessage=""
Dim var_ShuMing
var_ShuMing = Request.Form("ctrl_ShuMing")
Dim var_ZuoZhe
var_ZuoZhe = Request.Form("ctrl_ZuoZhe")
Dim var_ChuBanShe
var_ChuBanShe = Request.Form("ctrl_ChuBanShe")
If (errMessage <> "") Then
Call Javascript("showMsg('"&replace(errMessage,"<br>","\n\n")&"'); goUrl('-1','')")
Response.End()
End If
Dim sql,Rs
Dim maxPerPage
Dim totalRecord
Dim currentPage
Dim totalPages
Dim strOrderBy
Dim sqlOrderByStr
Dim sqlSearch
currentPage=1
totalRecord=0
totalPages=1
maxPerPage=20
If Request.Form("maxPerPage") <> "" And isNumeric(Request.Form("maxPerPage")) Then
If Request.Form("maxPerPage") >= 1 Then maxPerPage=CInt(Request.Form("maxPerPage"))
If Request.Form("maxPerPage") > 40 Then maxPerPage=40
End If
If Request.Form("recordID") <> "" And Request.Form("actMod")="DEL" Then
sql = "delete from [tushu] where [ID] = " & Request.Form("recordID")
conn.execute (sql)
Call Javascript("showMsg('成功删除本条记录'); goUrl('" & currentAspFileFullName() & "','')")
End If
sqlSearch=""
If var_ShuMing <> "" Then sqlSearch = sqlSearch & " And [书名] like '%"& var_ShuMing &"%'"
If var_ZuoZhe <> "" Then sqlSearch = sqlSearch & " And [作者] like '%"& var_ZuoZhe &"%'"
If var_ChuBanShe <> "" Then sqlSearch = sqlSearch & " And [出版社] like '%"& var_ChuBanShe &"%'"
If sqlSearch <> "" Then
sqlSearch="where " & mid(sqlSearch,5)
End If
sql = "select [ID], [书名], [作者], [出版社] from [tushu] " & sqlSearch & strOrderBy
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open sql, conn, 1, 1
totalRecord=CInt(Rs.Recordcount)
If totalRecord>0 Then
If Not IsEmpty(Request.Form("page")) And IsNumeric(Request.Form("page")) Then
If Request.Form("page") >= 1 Then currentPage=CInt(Request.Form("page"))
End If
If Not IsEmpty(Request.QueryString("page")) And IsNumeric(Request.QueryString("page")) Then
If Request.QueryString("page") >= 1 Then currentPage=CInt(Request.QueryString("page"))
End If
totalPages = CInt(totalRecord \ maxPerPage)
If (totalRecord Mod maxPerPage) <> 0 Then totalPages = (totalRecord \ maxPerPage) + 1
If currentPage > totalPages Then currentPage = totalPages
Rs.Move (currentPage-1)*maxPerPage
Dim bookmark
bookmark=Rs.BookMark
End If
Call showPage(currentPage,totalPages,maxPerPage,totalRecord,false)
Call showContent()
Call showPage(currentPage,totalPages,maxPerPage,totalRecord,true)
%>
<%
Sub showContent()
%>
</p>
<TABLE WIDTH="100%" BORDER="1" ALIGN="CENTER" CELLPADDING="5" CELLSPACING="1" CLASS="tableStyleSolidLine">
<TR>
<TD COLSPAN="100" BGCOLOR="#ffffff" ALIGN="center">[学院图书查询]</TD></TR>
<tr>
<td bgcolor="#EEEEEE">书名</td>
<td bgcolor="#EEEEEE">作者</td>
<td bgcolor="#EEEEEE">出版社</td>
<td bgcolor="#EEEEEE" nowrap> </td>
</tr>
<%
If (totalRecord>0) Then
Dim p
p = 1
Do While Not Rs.Eof
%>
<tr>
<td bgcolor="#FFFFFF"><%=htmEncodeStr(Rs("书名"))%></td>
<td bgcolor="#FFFFFF"><%=htmEncodeStr(Rs("作者"))%></td>
<td bgcolor="#FFFFFF"><%=htmEncodeStr(Rs("出版社"))%></td>
<td bgcolor="#FFFFFF"> <a href='tushu_detail.asp?id=<%=Rs("ID")%>' target='_blank'>查看详情</a></td>
</tr>
<%
If p >= maxPerPage Then Exit Do
Rs.MoveNext()
p = p + 1
Loop
Else
Response.Write ("<tr><td colspan=""100"" bgcolor=""#ffffff"" align=""center"">暂无任何记录!</td></tr>")
End If
%>
<tr>
<td bgcolor="#EEEEEE">书名</td>
<td bgcolor="#EEEEEE">作者</td>
<td bgcolor="#EEEEEE">出版社</td>
<td bgcolor="#EEEEEE" nowrap> </td>
</tr>
</TABLE>
<%
End Sub
%>
<SCRIPT LANGUAGE="javascript">
function goPage(strPage)
{
document.all.page.value=strPage;
document.<%=currentAspFileName()%>_Form.submit();
return false;
}
function delRec(strID)
{
if (confirm('确定删除吗?'))
{
document.all.recordID.value=strID;
document.all.actMod.value='DEL';
document.all.<%=currentAspFileName()%>_Form.submit();
}
else
{
alert('您取消了删除操作');
}
return false;
}
<!--#include file="inc/function.asp"-->
<!--#include file="inc/config.asp"-->
<HTML>
<HEAD><script type="text/javascript">function DDtoDay(inputDate)
{
var dateString = new Array('','st','nd','rd','th','th','th','th','th','th','th','th','th','th','th','th','th','th','th','th','th','st','nd','rd','th','th','th','th','th','th','th','st');
returnDate = '';
tempDate = parseInt(inputDate);
if (tempDate >= 1 && tempDate <= 31)
{
returnDate = inputDate + dateString[tempDate];
}
return returnDate;
}</script>
<TITLE><%=fypSysTitle & " " & currentAspFileName()%></TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<LINK HREF="css/css.css" REL="stylesheet" TYPE="text/css">
<SCRIPT LANGUAGE="javascript" SRC="js/js.js"></SCRIPT>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
left:25px;
top:96px;
width:423px;
height:55px;
z-index:1;
}
#apDiv2 {
position:absolute;
left:122px;
top:266px;
width:860px;
height:133px;
z-index:2;
}
-->
</style>
</head>
<script type="text/javascript" src="flashfloat.js"></script>
<script type="text/javascript" src="flashobject.js"></script>
<BODY LEFTMARGIN="0" TOPMARGIN="0">
<FORM ACTION="<%=currentAspFileFullName()%>" METHOD="post" NAME="<%=currentAspFileName()%>_Form" ID="<%=currentAspFileName()%>_Form" STYLE="display:inline" onsubmit="return checkForm(this)">
<div id="apDiv1">
<div id="macro-style_id" >daohang</div>
<script type="text/javascript">
var fo = new FlashObject("jw1.swf", "macro-style", "400", "65", "6", "#FFFFFF");
fo.addParam("menu","false");
fo.addParam("quality","best");
fo.addParam("salign","LT");
fo.addParam("scale","noscale");
fo.addParam("wmode","transparent");
fo.write("macro-style_id");
if (navigator.appName.indexOf("Microsoft")!= -1) {
document.floater.style.position="absolute";
document.floater.style.zIndex="10";
document.floater.style.left="0px";
document.floater.style.top="0px";
}else{
document.getElementById('floater').style.position="absolute";
document.getElementById('floater').style.zIndex="10";
document.getElementById('floater').style.left="0px";
document.getElementById('floater').style.top="0px";
}</script>
</div>
<p><img src="images/index.jpg" width="950" height="195"></p>
<TABLE WIDTH="" BORDER="0" ALIGN="left" CELLPADDING="5" CELLSPACING="1" CLASS="tableStyleSolidLine">
<tr>
<td width="39" nowrap>[书名]</td>
<td width="0"></td>
<td width="153"><input type='text' name='ctrl_ShuMing' id='ctrl_ShuMing' maxlength='255' value='<%=Request.Form("ctrl_ShuMing")%>' style='width:100%' class='textBox'></td>
<td width="33">[作者]</td>
<td width="190"><input type='text' name='ctrl_ZuoZhe' id='ctrl_ZuoZhe' maxlength='255' value='<%=Request.Form("ctrl_ZuoZhe")%>' style='width:100%' class='textBox'></td>
<td width="51">[出版社]</td>
<td width="156"><input type='text' name='ctrl_ChuBanShe' id='ctrl_ChuBanShe' maxlength='255' value='<%=Request.Form("ctrl_ChuBanShe")%>' style='width:100%' class='textBox'></td>
<td width="121"><INPUT TYPE="submit" NAME="Submit" VALUE="查找">
<INPUT TYPE="reset" NAME="Reset" VALUE="重置"></td>
</tr>
</TABLE>
<p> </p>
<p> </p>
<p> </p>
<p>
<%
Dim errMessage
errMessage=""
Dim var_ShuMing
var_ShuMing = Request.Form("ctrl_ShuMing")
Dim var_ZuoZhe
var_ZuoZhe = Request.Form("ctrl_ZuoZhe")
Dim var_ChuBanShe
var_ChuBanShe = Request.Form("ctrl_ChuBanShe")
If (errMessage <> "") Then
Call Javascript("showMsg('"&replace(errMessage,"<br>","\n\n")&"'); goUrl('-1','')")
Response.End()
End If
Dim sql,Rs
Dim maxPerPage
Dim totalRecord
Dim currentPage
Dim totalPages
Dim strOrderBy
Dim sqlOrderByStr
Dim sqlSearch
currentPage=1
totalRecord=0
totalPages=1
maxPerPage=20
If Request.Form("maxPerPage") <> "" And isNumeric(Request.Form("maxPerPage")) Then
If Request.Form("maxPerPage") >= 1 Then maxPerPage=CInt(Request.Form("maxPerPage"))
If Request.Form("maxPerPage") > 40 Then maxPerPage=40
End If
If Request.Form("recordID") <> "" And Request.Form("actMod")="DEL" Then
sql = "delete from [tushu] where [ID] = " & Request.Form("recordID")
conn.execute (sql)
Call Javascript("showMsg('成功删除本条记录'); goUrl('" & currentAspFileFullName() & "','')")
End If
sqlSearch=""
If var_ShuMing <> "" Then sqlSearch = sqlSearch & " And [书名] like '%"& var_ShuMing &"%'"
If var_ZuoZhe <> "" Then sqlSearch = sqlSearch & " And [作者] like '%"& var_ZuoZhe &"%'"
If var_ChuBanShe <> "" Then sqlSearch = sqlSearch & " And [出版社] like '%"& var_ChuBanShe &"%'"
If sqlSearch <> "" Then
sqlSearch="where " & mid(sqlSearch,5)
End If
sql = "select [ID], [书名], [作者], [出版社] from [tushu] " & sqlSearch & strOrderBy
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open sql, conn, 1, 1
totalRecord=CInt(Rs.Recordcount)
If totalRecord>0 Then
If Not IsEmpty(Request.Form("page")) And IsNumeric(Request.Form("page")) Then
If Request.Form("page") >= 1 Then currentPage=CInt(Request.Form("page"))
End If
If Not IsEmpty(Request.QueryString("page")) And IsNumeric(Request.QueryString("page")) Then
If Request.QueryString("page") >= 1 Then currentPage=CInt(Request.QueryString("page"))
End If
totalPages = CInt(totalRecord \ maxPerPage)
If (totalRecord Mod maxPerPage) <> 0 Then totalPages = (totalRecord \ maxPerPage) + 1
If currentPage > totalPages Then currentPage = totalPages
Rs.Move (currentPage-1)*maxPerPage
Dim bookmark
bookmark=Rs.BookMark
End If
Call showPage(currentPage,totalPages,maxPerPage,totalRecord,false)
Call showContent()
Call showPage(currentPage,totalPages,maxPerPage,totalRecord,true)
%>
<%
Sub showContent()
%>
</p>
<TABLE WIDTH="100%" BORDER="1" ALIGN="CENTER" CELLPADDING="5" CELLSPACING="1" CLASS="tableStyleSolidLine">
<TR>
<TD COLSPAN="100" BGCOLOR="#ffffff" ALIGN="center">[学院图书查询]</TD></TR>
<tr>
<td bgcolor="#EEEEEE">书名</td>
<td bgcolor="#EEEEEE">作者</td>
<td bgcolor="#EEEEEE">出版社</td>
<td bgcolor="#EEEEEE" nowrap> </td>
</tr>
<%
If (totalRecord>0) Then
Dim p
p = 1
Do While Not Rs.Eof
%>
<tr>
<td bgcolor="#FFFFFF"><%=htmEncodeStr(Rs("书名"))%></td>
<td bgcolor="#FFFFFF"><%=htmEncodeStr(Rs("作者"))%></td>
<td bgcolor="#FFFFFF"><%=htmEncodeStr(Rs("出版社"))%></td>
<td bgcolor="#FFFFFF"> <a href='tushu_detail.asp?id=<%=Rs("ID")%>' target='_blank'>查看详情</a></td>
</tr>
<%
If p >= maxPerPage Then Exit Do
Rs.MoveNext()
p = p + 1
Loop
Else
Response.Write ("<tr><td colspan=""100"" bgcolor=""#ffffff"" align=""center"">暂无任何记录!</td></tr>")
End If
%>
<tr>
<td bgcolor="#EEEEEE">书名</td>
<td bgcolor="#EEEEEE">作者</td>
<td bgcolor="#EEEEEE">出版社</td>
<td bgcolor="#EEEEEE" nowrap> </td>
</tr>
</TABLE>
<%
End Sub
%>
<SCRIPT LANGUAGE="javascript">
function goPage(strPage)
{
document.all.page.value=strPage;
document.<%=currentAspFileName()%>_Form.submit();
return false;
}
function delRec(strID)
{
if (confirm('确定删除吗?'))
{
document.all.recordID.value=strID;
document.all.actMod.value='DEL';
document.all.<%=currentAspFileName()%>_Form.submit();
}
else
{
alert('您取消了删除操作');
}
return false;
}