一共2页 你再把这个页改动成我这样,看searchbook.asp
1.
<script language = "JavaScript">
function validata_form() {
if (checkspace(document.form.s_book.value))
{
alert('请输入关键字!');
document.form.s_book.focus();
}
function checkspace(checkstr) {
var str = '';
for(i = 0; i < checkstr.length; i++) {
str = str + ' ';
}
return (str == checkstr);
}
</script>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<form action="searchbook.asp" method="post" name="form" onSubmit="return validata_form()">
<tr height=20>
<td width="140" class="xt" align=center style="padding-top:5;padding-bottom:5;border-top:#996633 1px solid;border-bottom:1px solid #996633;border-right:1px solid #996633 dashed;" valign=middle>【出版社·搜索】</td>
<td width="70" align="right" valign=middle class="xt" style="border-top:#996633 1px solid;border-bottom:1px solid #996633;padding-top:5;padding-bottom:5">关键字:</td>
<td width="400" align="center" valign=middle class="xt" style="border-top:#996633 1px solid;border-bottom:1px solid #996633;padding-top:5;padding-bottom:5"><input type="text" name="s_book" size=25 value="请输入" onFocus="this.value='';">
<select name="s_class">
<option value="Bl_name" selected>按出版社</option>
<option value="Ba_author">按ISBN号</option>
</select>
<input name="submit" type="submit" value=" 搜 索 " ></td>
</tr>
</form>
</table>
2.searchbook.asp
<table>
<tr>
<td align="center">编号</td>
<td align="center">书名</td>
</tr>
<%
set rs=server.CreateObject("adodb.recordset")
s_class=trim(request("s_class"))
s_book=trim(request("s_book"))
if s_class ="Bl_name" then
rs.open"select * from 数据库表 where 出版社 like '%" & s_book &"%'",conn,1,1
end if
if s_class ="Ba_author" then
rs.open"select * from 数据库表 where ISBN编号="&s_book,conn,1,1
end if
if not rs.eof and not rs.bof then
%>
<%
rs.PageSize =30'每页记录条数
iCount=rs.RecordCount '记录总数
iPageSize=rs.PageSize
maxpage=rs.PageCount
page=request("page")
if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if
if page<1 then
page=1
elseif page>maxpage then
page=maxpage
end if
rs.AbsolutePage=Page
if page=maxpage then
x=iCount-(maxpage-1)*iPageSize
else
x=iPageSize
end if
%>
<%
For i=1 To x
%>
<tr>
<td><%=trim(rs("编号"))%></td>
<td><%=trim(rs("书名"))%></td>
</tr>
<%
rs.movenext
next
%>
</table>
<table>
<tr>
<td>
<%
call PageControl(iCount,maxpage,page,"border=0 align=center","<p align=center>")
rs.close
set rs=nothing
Sub PageControl(iCount,pagecount,page,table_style,font_style)
Dim query, a, x, temp
action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")
query = Split(Request.ServerVariables("QUERY_STRING"), "&")
For Each x In query
a = Split(x, "=")
If StrComp(a(0), "page", vbTextCompare) <> 0 Then
temp = temp & a(0) & "=" & a(1) & "&"
End If
Next
Response.Write("<table " & Table_style & ">" & vbCrLf )
Response.Write("<form method=get onsubmit=""document.location = '" & action & "?" & temp & "Page='+ this.page.value;return false;""><TR>" & vbCrLf )
Response.Write("<TD align=right>" & vbCrLf )
Response.Write(font_style & vbCrLf )
if page<=1 then
Response.Write ("首页 " & vbCrLf)
Response.Write ("上页 " & vbCrLf)
else
Response.Write("<A HREF=" & action & "?" & temp & "Page=1>首页</A> " & vbCrLf)
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page-1) & ">上页</A> " & vbCrLf)
end if
if page>=pagecount then
Response.Write ("下页 " & vbCrLf)
Response.Write ("尾页 " & vbCrLf)
else
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page+1) & ">下页</A> " & vbCrLf)
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & pagecount & ">尾页</A> " & vbCrLf)
end if
Response.Write(" 页次:" & page & "/" & pageCount & "页" & vbCrLf)
Response.Write(" 共有" & iCount & "条信息" & vbCrLf)
Response.Write(" 转到" & "<INPUT TYEP=TEXT NAME=page SIZE=1 Maxlength=5 VALUE=" & page & ">" & "页" & vbCrLf & "<INPUT type=submit style=""font-size: 9pt"" value=GO class=b2>")
Response.Write("</TD>" & vbCrLf )
Response.Write("</TR></form>" & vbCrLf )
Response.Write("</table>" & vbCrLf )
End Sub
end if
%>
</td>
</tr>
</table>
[此贴子已经被作者于2006-9-9 10:16:11编辑过]