教程中国
PHOTOSHOP CS9.0中文版 MAYA 8.5 FOR WINDOWS Corel Painter v9.0 Flash MX2004 中文版 Illustrator cs2 中文版
VC++6.0含sp6 中英文版 VB6.0 +sp6 简体中文版 Borland Delphi 7汉化版 MSDN for vb6.0中文版 Visual Studio 2005简体
教程中国下属 文件存储共享专家BIBIDU.COM 提供大型软件,教材,源码,电影,音乐,图书等下载 更多精品请点此进入
  您目前所在位置: 教程中国 >> 编程基地 >> XML >> 使用XML、XSLT和XPath创建可排序、分页、重用的数据显示页 RSS订阅
使用XML、XSLT和XPath创建可排序、分页、重用的数据显示页
使用XML、XSLT和XPath创建可排序、分页、重用的数据显示页(3)
教程(视频,书籍)下载:  ASP.NET AutoCAD 数据库 C# ASP java photoshop 网页设计 delphi 3dmax Flash C++ VB 张孝祥 实例   更多请进入BIBIDU搜索
IT搜索引擎   
<STYLE>
body { font-family:宋体; font-size:9pt;}
th { font-family:宋体; font-size:11pt; font-weight:bold;}
</STYLE>
<Script language="vbscript">
Option Explicit

Dim intRecordsPerPage "每个页面显示的记录数
intRecordsPerPage = 6 "每个页面显示的记录数,默认设定为6



" 更新显示页面的函数
Function window_onload()

" 显示设定的记录数
Style.XMLDocument.selectNodes("//xsl:for-each/@select")(1).Value = "./*[position() < " & intRecordsPerPage + 1 & " and position() > 0]"
transform()
setPageCount()

End Function

" 进行XML-XSLT转换,并显示当前记录的一些信息
Function transform()

DisplayArea.innerHTML = Data.transformNode(Style.DocumentElement)
RecordsPerPage.Value = intRecordsPerPage

End Function

" 重新转换XML,并显示一个状态信息
Function redisplay(intPage)

Dim strDisplay
Dim intPageCount
Dim intRecordCount

" 保存状态信息
intPageCount = PageCount.innerHTML
intRecordCount = RecordCount.innerHTML
transform()
" 显示状态信息
PageCount.innerHTML = intPageCount
RecordCount.innerHTML = intRecordCount
CurrentPage.innerHTML = intPage

End Function

" 重新排序和显示
Function Sort(strField)

Dim sortField
Dim sortOrderAttribute
" 得到排序属性值
Set sortField = Style.XMLDocument.selectSingleNode("//xsl:sort/@select")
Set sortOrderAttribute = Style.XMLDocument.selectSingleNode("//xsl:sort/@order")

" 改变排序的方式
If sortField.Value = strField Or sortField.Value = "./*[0]" Then
If sortOrderAttribute.Value = "descending" Then
sortOrderAttribute.Value = "ascending"
Else
sortOrderAttribute.Value = "descending"
End If
Else
sortField.Value = strField
sortOrderAttribute.Value = "ascending"
End If

Set sortField = Nothing
Set sortOrderAttribute = Nothing

redisplay (CurrentPage.innerHTML)

End Function

" 重新设置每页的记录数
Function setRecordsPerPage()

If IsNumeric(RecordsPerPage.Value) Then
intRecordsPerPage = CInt(RecordsPerPage.Value)
window_onload
End If

End Function

" 显示页数信息
Function setPageCount()

Dim intTotalRecords

PageCount.innerHTML = getNumberOfPages(intTotalRecords)
RecordCount.innerHTML = intTotalRecords
CurrentPage.innerHTML = 1

End Function

" 计算总页数和总记录数
Function getNumberOfPages(intTotalRecords)

Dim intPages

intTotalRecords = Data.XMLDocument.selectNodes("/*/*").length
intPages = intTotalRecords / intRecordsPerPage
If InStr(intPages, ".") > 0 Then
intPages = CInt(Left(intPages, InStr(intPages, "."))) + 1
End If

getNumberOfPages = intPages

End Function

" “下一页”的处理
Function nextPage(intPage)

Dim strDisplay
Dim strDateRange

If CInt(CStr(intPage) * intRecordsPerPage) < Data.selectNodes("/*/*").length Then
intPage = CInt(intPage) + 1
Style.XMLDocument.selectNodes("//@OnClick")(1).Value = "previousPage(" & intPage & ")"
Style.XMLDocument.selectNodes("//@OnClick")(2).Value = "nextPage(" & intPage & ")"
Style.XMLDocument.selectNodes("//xsl:for-each/@select")(1).Value = "./*[position() <= " & (CStr(intPage) * intRecordsPerPage) & " and position() > " & (CInt(intPage) - 1) * intRecordsPerPage & "]"
redisplay (intPage)
End If

End Function

" 处理“上一页”
Function previousPage(intPage)

Dim strDisplay
Dim strDateRange

If intPage > 1 Then
intPage = CInt(intPage) - 1
Style.XMLDocument.selectNodes("//@OnClick")(1).Value = "previousPage(" & intPage & ")"
Style.XMLDocument.selectNodes("//@OnClick")(2).Value = "nextPage(" & intPage & ")"
Style.XMLDocument.selectNodes("//xsl:for-each/@select")(1).Value = "./*[position() <= " & (CStr(intPage) * intRecordsPerPage) & " and position() > " & (CInt(intPage) - 1) * intRecordsPerPage & "]"
redisplay (intPage)
End If

End Function

" “第一页”的处理
Function FirstPage()

Style.XMLDocument.selectNodes("//@OnClick")(1).Value = "previousPage(1)"
Style.XMLDocument.selectNodes("//@OnClick")(2).Value = "nextPage(1)"
Style.XMLDocument.selectNodes("//xsl:for-each/@select")(1).Value = "./*[position() < " & intRecordsPerPage + 1 & " and position() > 0]"
transform()
setPageCount()

End Function


" “最末页”的处理
Function LastPage()

Dim intTotalPages
Dim intTotalRecords

intTotalPages = getNumberOfPages(intTotalRecords)
nextPage (intTotalPages - 1)

End Function
</Script>
</Head>
<body>
<p align="center" style="font-weight:bold;font-size:12pt;color:#0000FF;border-bottom:3px double red;padding-bottom:5px">客户关系表</p>
<XML id="Data">
<客户关系表 xmlns:dt="urn:schemas-microsoft-com:datatypes">
<客户><序号 dt:dt="int">01</序号><姓名>Mi</姓名><电子邮件>water@21cn.com</电子邮件></客户>

来源:十度教育
作者:
关键字:数据显示页
发表日期:2006-9-5 14:41:51

网页显示有限 阅读全文请下载本文完整版WORD文档

上一篇:利用oleDB对象,将数据库中全部表转换成XML文件   下一篇:SQL Server和XML的集成


共4页 9 7 [1] [2] [3] [48 :>

2009-1-8 7:26:20
本文的相类似文章
  • 使用XML、XSLT和XPath创建可排序、分页、重用的数据显示页
  • XML创建可排序、分页的数据显示页面
  • ASP 关于动态数据显示页面的锚点
  • XML创建可排序、分页的数据显示页面
  • 在学习中进步 在进步中成长 教程中国相随您的成长之路
    华腾联合科技股份有限公司版权所有
    广告联系:Rosibo@163.com