扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:青苹果工作室(编译) 来源:yesky 2007年10月26日
关键字: Windows
<% Class dhtmlGetRows '******* PRIVATE MEMBER VARIABLES ********** Private iRecsPerPage Private strTHString '******************************************* '************ Initialize Event ************* Private Sub Class_Initialize() iRecsPerPage = 10 'assign a default value End Sub '******************************************* '************ PROPERTY LET/GET ************* Public Property Let THString(strValue) 'Replace all apostrophes with \' strTHString = Replace(strValue, "'", "\'") End Property Public Property Get THString() THString = strTHString End Property Public Property Let RecsPerPage(iValue) If iValue > 0 and IsNumeric(iValue) then iRecsPerPage = CInt(iValue) End If End Property Public Property Get RecsPerPage() RecsPerPage = iRecsPerPage End Property '******************************************* '**************** METHODS ****************** Public Function GenerateHTML(objRS) 'Begin by getting an array of the data Dim aValues aValues = objRS.GetRows() 'Find the value of rows and columns Dim iCols, iRows iCols = UBound(aValues, 1) iRows = UBound(aValues, 2) Dim strOutput 'Display the initial script block strOutput = "<script language=""javascript"">" & vbCrLf & _ "var tableRow = new Array(" & iRows & ");" & vbCrLf & vbCrLf Dim iLoop, iColLoop, strTmp For iLoop = 0 to iRows strOutput = strOutput & "tableRow[" & iLoop & "] = '<tr>" For iColLoop = 0 to iCols 'Fix apostrophes strTmp = Replace(aValues(iColLoop, iLoop),"'", "\'") 'Remove carraige returns strTmp = Replace(strTmp, vbCrLf, "") strOutput = strOutput & "<td>" & strTmp & "</td>" Next 'iColLoop strOutput = strOutput & "</tr>';" & vbCrLf Next 'iLoop 'Init global varaibles and find out what browser the user is using strOutput = strOutput & vbCrLf & vbCrLf & "var first = 0;" & vbCrLf & _ "var last = " & iRecsPerPage & ";" & vbCrLf & _ "var mynav;" & vbCrLf & "if (navigator.appName == ""Netscape"")" & _ vbCrLf & vbTab & "mynav = ""NS"";" & vbCrLf & _ "if (navigator.appName == ""Microsoft Internet Explorer"")" & _ vbCrLf & vbTab & "mynav = ""IE"";" & vbCrLf & _ vbCrLf & "</script>" & vbCrLf & vbCrLf 'Now display the HTML table strOutput = strOutput & vbCrLf & "<div id=""grid""> </div>" & vbCrLf & _ vbCrLf & vbCrLf & "<script language=""javascript"">" & vbCrLf 'Write the nav function strOutput = strOutput & "function nav(iVal) {" & vbCrLf & _ "// do we want to move forward or backwards?" & vbCrLf & _ "if (iVal == 1) { " & vbCrLf & vbTab & "first += " & _ iRecsPerPage & ";" & vbCrLf & "last += " & iRecsPerPage & _ vbCrLf & "}" & vbCrLf & "else if (iVal == -1) { " & vbCrLf & vbTab & _ "first -= " & iRecsPerPage & ";" & vbCrLf & vbTab & "last -= " & _ iRecsPerPage & ";" & vbCrLf & "}" & vbCrLf & _ vbCrLf & vbCrLf & "var txt = '';" & vbCrLf & _ "txt += '<table border=""1"">';" & vbCrLf 'Do we need to add a TH string? If Len(strTHString) > 0 then strOutput = strOutput & "txt += '<tr>" & strTHString & "</tr>';" & vbCrLf End If strOutput = strOutput & "for (var iLoop = first; iLoop < last; iLoop++)" & vbCrLf & _ vbTab & "if (iLoop <= " & iRows & ") txt += tableRow[iLoop];" & vbCrLf & _ "txt += '</table>';" & vbCrLf & vbCrLf 'Now, show next/prev links if applicable strOutput = strOutput & "if (first > 0) // show prev link" & vbCrLf & _ vbTab & "txt += '<a href=""javascript:nav(-1);"">Prev " & _ iRecsPerPage & "</a> ';" & vbCrLf & vbCrLf & _ "if (last <= " & iRows & ") // show next link" & vbCrLf & vbTab & _ "txt += '<a href=""javascript:nav(1);"">Next " & _ iRecsPerPage & "</a>';" & vbCrLf & vbCrLf 'Write out the new HTML content to the DIV tag strOutput = strOutput & "// write out the the DIV tag depending on browser..." & vbCrLf & _ "if (mynav == ""NS"") {" & vbCrLf & vbTab & _ "document.layers['grid'].document.write(txt);" & vbCrLf & vbTab & _ "document.close();" & vbCrLf & "}" & vbCrLf & vbCrLf & _ "if (mynav == ""IE"")" & vbCrLf & vbTab & _ "document.all['grid'].innerHTML = txt;" & vbCrLf & vbCrLf & _ "}" & vbCrLf & vbCrLf strOutput = strOutput & "nav(0);" & vbCrLf & "</script>" GenerateHTML = strOutput End Function '******************************************* End Class %> |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者