Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort HTML table

Status
Not open for further replies.

gooseriver

IS-IT--Management
Joined
Aug 4, 2006
Messages
93
Location
CA
the html table consists of File Name, Size and Date/Time. Right now there is no sort in the html table.
I want the table to be sorted by the last column date/time in asc order... I dont want to have any of this
clicking on the headers to sort. Just simply a sort right away. Here is my code:

If (objFSO.FolderExists(strPhysicalPath)) then
Set objFolder = objFSO.GetFolder(strPhysicalPath)
Set objCollection = objFolder.Files

maxIndex = lCurrentPage * lPageSize
minIndex = (lCurrentPage-1) * lPageSize + 1

filFileName = request("FilFileName")
filDateFrom = request("FilDateFrom")
filDateTo = request("FilDateTo")

intRecord = 0
Index = 0
For Each objItem in objCollection

strName = objItem.Name
dtmDate = CDate(objItem.DateLastModIfied)
strFile = Server.HTMLEncode(strName)
intSizeB = objItem.Size

bDisplayFlag = true
If filFileName <> "" And filFileName <> "*" And NOT ISNULL(filFileName ) then
If Right(filFileName,1) = "*" Then
filFileName = Left(filFileName, Len(filFileName)-1)
End If
If Instr(UCase(strName), UCase(filFileName)) <> 1 Then
bDisplayFlag = false
End If
End If
If filDateFrom <> "" And filDateFrom <> "*" And NOT ISNULL(filDateFrom ) then
If FormatDateTime(filDateFrom,vbShortDate) > FormatDateTime(dtmDate,vbShortDate) Then
bDisplayFlag = false
End If
End If
If filDateTo <> "" And filDateTo <> "*" And NOT ISNULL(filDateTo ) then
If FormatDateTime(filDateTo,vbShortDate) < FormatDateTime(dtmDate,vbShortDate) Then
bDisplayFlag = false
End If
End If

If lBatchReportType="0" Then 'For single select
If Left(strFile,1) <> prxFix Then
bDisplayFlag = false
End If
End If

If bDisplayFlag = true Then

Index = Index + 1
If Index <=maxIndex and Index >=minIndex then

%>
<tr class="Row<%=((intRecord + 1)mod 2) + 1%>" onclick="javascript:if(typeof(GoViewFile)=='function') GoViewFile('<%=intRecord%>','0', '<%=strFile%>');document.frmList.rdo<%=intRecord%>.checked=true;" onmouseout="this.style.color='black'" onmouseover="this.style.color='Red'; this.style.cursor='hand';">
<td><input type="radio" id="rdo<%=intRecord%>" name="chkFiles" value = "<%=strFile%>" onclick="javascript:if(typeof(GoDocSelect)=='function') GoDocSelect('<%=intRecord%>','0', '<%=strFile%>'); event.cancelBubble=true;"></td>
<td align="left"><%=strFile%></td>
<td align="right"><%=FormatNumber(intSizeB,0)%> bytes</td>
<td align="left"><%=FormatDateTime(dtmDate,vbShortDate) & " " & FormatDateTime(dtmDate,vbLongTime)%></td>
</tr>

<%
intRecord = intRecord + 1
End If
End If
Next
End If
 
The only way I know how to sort items outside a database/spreadsheet would be to read the items into an array and then sort the array.

Here is a sample sorted array, hopefully it will give you a start.

Code:
' Sort Data with Bubble Sort

' Windows Server 2003 : Yes
' Windows XP : Yes
' Windows 2000 : Yes
' Windows NT 4.0 : Yes
' Windows 98 : Yes


arrSample = Array(4, 6, 2, 7, 3, 5, 1)
WScript.Echo vbCrLf & "array before"
For Each intNumber In arrSample
  WScript.Echo intNumber
Next
For i = LBound(arrSample) to UBound(arrSample)
  For j = LBound(arrSample) to UBound(arrSample)
    If j <> UBound(arrSample) Then
      If arrSample(j) > arrSample(j + 1) Then
         TempValue = arrSample(j + 1)
         arrSample(j + 1) = arrSample(j)
         arrSample(j) = TempValue
      End If
    End If
  Next
Next
WScript.Echo vbCrLf & "array after"
For Each intNumber In arrSample
  WScript.Echo intNumber
Next



Thanks

John Fuhrman
Titan Global Services
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top