list.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>default</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
*
{
margin:0;
padding:0;
}
#contain
{
width:770px;
margin:10px auto;
}
#header
{
width:768px;
border:1px solid #eeaaee;
margin-bottom:10px;
height:100px;
}
#main
{
width:770px;
margin-bottom:10px;
}
#main_L
{
width:148px;
border:1px solid #eeaaee;
float:left;
margin-right:10px;
height:400px;
}
#main_M
{
width:348px;
border:1px solid #eeaaee;
float:left;
margin-right:10px;
height:400px;
}
#main_R
{
width:248px;
border:1px solid #eeaaee;
float:left;
height:300px;
}
#footer
{
width:768px;
border:1px solid #eeaaee;
height:40px;
}
</style>
</head>
<body onLoad="FF()">
<div id="contain">
<div id="header">rr</div>
<div id="main">
<div id="main_L">rr</div>
<div id="main_M"></div>
<div id="main_R">rr</div>
<br style="clear:both">
</div>
<div id="footer">rr</div>
</div>
<script type="text/javascript">
function FF(y) {
if (!y) {
y=1;
}
var xmlhttp;
if (window.ActiveXObject) {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
}
if (xmlhttp) {
xmlhttp.onreadystatechange=function () {
if(xmlhttp.readyState==4) {
if(xmlhttp.status==200) {
var yy=unescape(xmlhttp.responseText);
show(yy);
}else {
alert("error");
}
}
}
xmlhttp.open("get","page.asp?page="+y);
xmlhttp.send(null);
}
}
function show(text) {
document.getElementById("main_M").innerHTML=text;
}
</script>
</body>
</html>
page.asp
<%
dim conn,rs
dim connstr,sqlcmd
set conn=server.CreateObject("ADODB.connection")
connstr="Driver={Microsoft Access Driver (*.mdb)};dbq="&server.MapPath("mydata.mdb")
conn.open connstr
sqlcmd="select id,name,tel from contact"
set rs=server.CreateObject("ADODB.recordset")
rs.open sqlcmd,conn,1,1
rs.pagesize=6
page=clng(request.QueryString("page"))
if page<1 then page=1
if page>rs.pagecount then page=rs.pagecount
rs.absolutepage=page
response.Write("<table width='300px' border='1'>")
for i=1 to rs.pagesize
response.Write("<tr>")
response.Write("<td>"&rs(0)&"</td>")
response.Write("<td>"&escape(rs(1))&"</td>")
response.Write("<td>"&rs(2)&"</td>")
response.Write("</tr>")
rs.movenext
if rs.EOF then exit for
next
response.Write("</table>")
if page=1 then
response.write(escape("首页 上一页"))
response.write("<a href='javascript:FF("&(page+1)&")'>"&escape("下一页")&"</a>")
response.write("<a href='javascript:FF("&rs.pagecount&")'>"&escape("末页")&"</a>")
elseif page=rs.pagecount then
response.write("<a href='javascript:FF(1)'>"&escape("首页")&"</a>")
response.write("<a href='javascript:FF("&(page-1)&")'>"&escape("上一页")&"</a>")
response.write(escape("下一页 末页"))
else
response.write("<a href='javascript:FF(1)'>"&escape("首页")&"</a>")
response.write("<a href='javascript:FF("&(page-1)&")'>"&escape("上一页")&"</a>")
response.write("<a href='javascript:FF("&(page+1)&")'>"&escape("下一页")&"</a>")
response.write("<a href='javascript:FF("&rs.pagecount&")'>"&escape("末页")&"</a>")
end if
%>
注:数据库为mydata.mdb 表名:contact 字段:id,name,tel
posted on 2008-04-02 23:05
影子 阅读(90)
评论(0) 编辑 收藏 所属分类:
学习笔记