⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sort2.htm

📁 《XML语言及应用》作者华铨平—examples
💻 HTM
字号:
<HTML> 
<Head> 
	<META http=equiv="Content-Type" Content="text/html;charset=gb2312"/> 
	<STYLE> 
	   body { font-family:宋体; font-size:9pt;} 
	   th { font-family:宋体; font-size:9pt; font-weight:bold;} 
	</STYLE> 
	<Script language="vbscript"> 
		Option Explicit 
		Dim intTotalRecords
		Dim intTotalPages
		Dim intCurPageNum
		Dim intRecordsPerPage   '每个页面显示的记录数
		intRecordsPerPage = 8   '每个页面显示的记录数,默认设定为6
		intCurPageNum = 1
				
		Function window_onload()  	' 更新显示页面的函数 
			' 显示设定的记录数 
			Style.XMLDocument.selectSingleNode("//table[@id='table2']/xsl:for-each/@select").Value = "./*[position() < " & intRecordsPerPage + 1 & " and position() > 0]" 
			DisplayArea.innerHTML = Data.transformNode(Style.DocumentElement) 
			intTotalPages = getNumberOfPages()
			PageCount.innerHTML 	= intTotalPages
			RecordCount.innerHTML	= intTotalRecords 
			CurrentPage.innerHTML 	= intCurPageNum
			RecordsPerPage.Value  = intRecordsPerPage
			alert("wwww")
		End Function 

		Function redisplay() 		' 重新转换XML,并显示一个状态信息
			intTotalPages = PageCount.innerHTML 
			intTotalRecords  = RecordCount.innerHTML
			intCurPageNum = CurrentPage.innerHTML
			intRecordsPerPage = RecordsPerPage.Value 
 
			DisplayArea.innerHTML = Data.transformNode(Style.DocumentElement) 
			intTotalPages = getNumberOfPages()
			PageCount.innerHTML 	= intTotalPages
			RecordCount.innerHTML	= intTotalRecords 
			CurrentPage.innerHTML 	= intCurPageNum
			RecordsPerPage.Value  = intRecordsPerPage
		End Function 

		Function Sort(strField)   ' 重新排序和显示 
			Dim sortField 
			Dim sortOrderAttribute 
			' 得到排序属性值 
			Set sortField = Style.XMLDocument.selectSingleNode("//table[@id='table2']/xsl:for-each/xsl:sort/@select") 
			Set sortOrderAttribute = Style.XMLDocument.selectSingleNode("//table[@id='table2']/xsl:for-each/xsl:sort/@order") 
			' 改变排序的方式 
			
			If sortField.Value = strField 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 () 
			
			
			
		End Function 
   

		Function Gopages(pages) 
			intTotalPages = getNumberOfPages()   	'求数据记录个数 and 求pages  也得到intTotalRecords 的值
			Dim firstNum 
			Dim lastNum 
			If pages="first" Then
				intCurPageNum=1
			End If
			 
			If pages="previous" Then
				If  intCurPageNum > 1 Then
					intCurPageNum = intCurPageNum - 1
				End If
			End If
			
			If pages="next" Then
				If intCurPageNum < intTotalPages Then
					intCurPageNum = intCurPageNum + 1
				End IF
			End If
			
			If pages="last" Then
				intCurPageNum = intTotalPages
			End If
		
			firstNum=intRecordsPerPage*(intCurPageNum-1)+1 
			lastNum=intRecordsPerPage*intCurPageNum
			Style.XMLDocument.selectSingleNode("//table[@id='table2']/xsl:for-each/@select").Value = "./*[position() <= " & CStr(firstNum) & " and position() > " & CInt(lastNum)& "]" 
			redisplay () 
		End Function 


		Function setRecordsPerPage()     ' 重新设置每页的记录数 
			If IsNumeric(RecordsPerPage.Value) Then 
				intRecordsPerPage = CInt(RecordsPerPage.Value) 
				window_onload 
			End If 
		End Function 

		Function getNumberOfPages() 	' 计算总页数和总记录数 
   			Dim intPages 
			intTotalRecords = Data.XMLDocument.selectNodes("/*/*").length 
			intPages = intTotalRecords / intRecordsPerPage 
			If InStr(intPages, ".") > 0 Then 
				intPages = CInt(Left(intPages, InStr(intPages, "."))) + 1 
			End If 
			intTotalPages  = intPages
			getNumberOfPages = intPages 
		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'  src='sort1.xml'></XML> 
<XML id='Style' src='sort2.xsl'></XML> 
<div id="DisplayArea"></div> 
<div id="DisplayTest"></div> 
</body> 
</HTML> 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -