':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: test harness :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
' to test, we'll just try to show all files with a .gif extension in the root of c:
set objfso = createobject("scripting.filesystemobject")
set objf = objfso.getfolder("c:\")
set objfc = objf.files
response.write "<table border=""0"" cellpadding=""5"">"
for each f1 in objfc
if instr(ucase(f1.name), ".gif") then
response.write "<tr><td>" & f1.name & "</td><td>" & f1.datecreated & "</td><td>" & f1.size & "</td><td>"
if gfxspex(f1.path, w, h, c, strtype) = true then
response.write w & " x " & h & " " & c & " colors"
else
response.write " "
end if
response.write "</td></tr>"
end if
next
response.write "</table>"
set objfc = nothing
set objf = nothing
set objfso = nothing
set rs=server.createobject("adodb.recordset") ''创建recordset对象
rs.cursorlocation=aduseclient ''设定记录集指针属性
''*设定一页内的记录总数,可根据需要进行调整
rs.pagesize=10
''*设置查询语句
strsql="select id,姓名,住址,电话 from 通讯录 order by id"
rs.open strsql,conn,adopenstatic,adlockreadonly,adcmdtext
%>
<html>
<head>
<title>分页示例</title>
<script language=javascript>
//点击"[第一页]"时响应:
function pagefirst()
{
document.myform.currentpage.selectedindex=0;
document.myform.currentpage.onchange();
}
//点击"[上一页]"时响应:
function pageprior()
{
document.myform.currentpage.selectedindex--;
document.myform.currentpage.onchange();
}
//点击"[下一页]"时响应:
function pagenext()
{
document.myform.currentpage.selectedindex++;
document.myform.currentpage.onchange();
}
//点击"[最后一页]"时响应:
function pagelast()
{
document.myform.currentpage.selectedindex=document.myform.currentpage.length-1;
document.myform.currentpage.onchange();
}
//选择"第?页"时响应:
function pagecurrent()
{ //pages.asp是本程序的文件名
document.myform.action='pages.asp?page='+(document.myform.currentpage.selectedindex+1)
document.myform.submit();
}
</script>
</head>
<body bgcolor="#ffffcc" link="#008000" vlink="#008000" alink="#ff0000"">
<%if rs.eof then
response.write("<font size=2 color=#000080>[数据库中没有记录!]</font>")
else
''指定当前页码
if request("currentpage")="" then
rs.absolutepage=1
else
rs.absolutepage=clng(request("currentpage"))
end if
''创建表单myform,方法为get
response.write("<form method=get name=myform>")
response.write("<p align=center><font size=2 color=#008000>")
''设置翻页超链接
if rs.pagecount=1 then
response.write("[第一页] [上一页] [下一页] [最后一页] ")
else
if rs.absolutepage=1 then
response.write("[第一页] [上一页] ")
response.write("[<a href=java script:pagenext()>下一页</a>] ")
response.write("[<a href=java script:pagelast()>最后一页</a>] ")
else
if rs.absolutepage=rs.pagecount then
response.write("[<a href=java script:pagefirst()>第一页</a>] ")
response.write("[<a href=java script:pageprior()>上一页</a>] ")
response.write("[下一页] [最后一页] ")
else
response.write("[<a href=java script:pagefirst()>第一页</a>] ")
response.write("[<a href=java script:pageprior()>上一页</a>] ")
response.write("[<a href=java script:pagenext()>下一页</a>] ")
response.write("[<a href=java script:pagelast()>最后一页</a>] ")
end if
end if
end if
''创建下拉列表框,用于选择浏览页码
response.write("第<select size=1 name=currentpage onchange=pagecurrent()>")
for i=1 to rs.pagecount
if rs.absolutepage=i then
response.write("<option selected>"&i&"</option>") ''当前页码
else
response.write("<option>"&i&"</option>")
end if
next
response.write("</select>页/共"&rs.pagecount&"页 共"&rs.recordcount&"条记录</font><p>")
response.write("</form>")
''显示表头
for i=0 to columns.count-1
response.write("<td align=center width=200 height=13>")
response.write("<font size=2><b>"&columns(i).name&"</b></font></td>")
next
response.write("</tr>")
''显示内容
for i=1 to rs.pagesize
response.write("<tr bgcolor=#99ccff bordercolor=#000066>")
for j=0 to columns.count-1
response.write("<td><font size=2>"&columns(j)&"</font></td>")
next
response.write("</tr>")
rs.movenext
if rs.eof then exit for
next
response.write("</table>")
end if
%>
</body>
</html>作者: kalidoit 时间: 2006-11-13 10:27