By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,857 Members | 1,768 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,857 IT Pros & Developers. It's quick & easy.

list documents in a html table

P: n/a
Ken
I currently have a set of documents in a directory that i need to list in a
html table. Is there any way to generate the table with the documents listed
instead of having to update the table manually everytime a new document is
added to the list.

Thanks
Ken
Jul 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Where is this directory? Is it on the IIS server? I'm going to assume for
the moment that the directory is on the IIS server. There are at least two
options. 1 is to just enable directory browsing for the directory and not
have a default page for the directory (default.htm, default.asp, etc.). If
you'd like to make things prettier, you can use the FSO and do something
like:

<table>
<tr>
<td>File name</td>
<td>Last modified</td>
</tr>

<%
Dim oFSO, oFiles, oFile
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFiles = oFSO.GetFolder("D:\PathOnServer").Files
For Each oFile in oFiles
%>
<tr>
<td><%=oFile.Name%></td>
<td><%=oFile.DateLastModified%></td>
</tr>
<%
Next

Set oFiles = Nothing
Set oFSO = Nothing
%>
</table>

IUSR will need permission to read the directory if you're using anonymous
access on your site (default).

Ray at work

"Ken" <kl*****@spamfreeingr.com> wrote in message
news:uk**************@TK2MSFTNGP12.phx.gbl...
I currently have a set of documents in a directory that i need to list in a html table. Is there any way to generate the table with the documents listed instead of having to update the table manually everytime a new document is
added to the list.

Thanks
Ken

Jul 19 '05 #2

P: n/a
Ken,

How about you save them in a database table.

Quewry your table and loop through each record
interweaving it with HTML and that would save you
changing your HTML code each time.
-----Original Message-----
I currently have a set of documents in a directory that i need to list in ahtml table. Is there any way to generate the table with the documents listedinstead of having to update the table manually everytime a new document isadded to the list.

Thanks
Ken
.

Jul 19 '05 #3

P: n/a
Ken
Thanks for the response.
This is just what I need. One more question. How can I create a link to the
files after they are listed so that they can be opened up?

Thanks again
Ken
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:um*************@TK2MSFTNGP11.phx.gbl...
Where is this directory? Is it on the IIS server? I'm going to assume for the moment that the directory is on the IIS server. There are at least two options. 1 is to just enable directory browsing for the directory and not
have a default page for the directory (default.htm, default.asp, etc.). If you'd like to make things prettier, you can use the FSO and do something
like:

<table>
<tr>
<td>File name</td>
<td>Last modified</td>
</tr>

<%
Dim oFSO, oFiles, oFile
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFiles = oFSO.GetFolder("D:\PathOnServer").Files
For Each oFile in oFiles
%>
<tr>
<td><%=oFile.Name%></td>
<td><%=oFile.DateLastModified%></td>
</tr>
<%
Next

Set oFiles = Nothing
Set oFSO = Nothing
%>
</table>

IUSR will need permission to read the directory if you're using anonymous
access on your site (default).

Ray at work

"Ken" <kl*****@spamfreeingr.com> wrote in message
news:uk**************@TK2MSFTNGP12.phx.gbl...
I currently have a set of documents in a directory that i need to list in
a
html table. Is there any way to generate the table with the documents

listed
instead of having to update the table manually everytime a new document

is added to the list.

Thanks
Ken


Jul 19 '05 #4

P: n/a
Generate the HTML that would provide a link. What do you want the resultant
HTML to look like? You'd want it to look like:
<td><A href="filex.doc">filex.doc</a></td>

right? What is filex.doc? It's the current .Name property of the current
file while looping. So, to get that resultant HTML, you'd do:
'''other code
For Each oFile in oFiles
%>
<tr>
<td><A href="<%=oFile.Name%>"><%=oFile.Name%></A></td>
<td><%=oFile.DateLastModified%></td>
</tr>
<%
Next
'''other code
Ray at work


"Ken" <kl*****@spamfreeingr.com> wrote in message
news:uq**************@TK2MSFTNGP11.phx.gbl...
Thanks for the response.
This is just what I need. One more question. How can I create a link to the files after they are listed so that they can be opened up?

Thanks again
Ken
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:um*************@TK2MSFTNGP11.phx.gbl...
Where is this directory? Is it on the IIS server? I'm going to assume for
the moment that the directory is on the IIS server. There are at least

two
options. 1 is to just enable directory browsing for the directory and not
have a default page for the directory (default.htm, default.asp, etc.).

If
you'd like to make things prettier, you can use the FSO and do something
like:

<table>
<tr>
<td>File name</td>
<td>Last modified</td>
</tr>

<%
Dim oFSO, oFiles, oFile
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFiles = oFSO.GetFolder("D:\PathOnServer").Files
For Each oFile in oFiles
%>
<tr>
<td><%=oFile.Name%></td>
<td><%=oFile.DateLastModified%></td>
</tr>
<%
Next

Set oFiles = Nothing
Set oFSO = Nothing
%>
</table>

IUSR will need permission to read the directory if you're using anonymous access on your site (default).

Ray at work

"Ken" <kl*****@spamfreeingr.com> wrote in message
news:uk**************@TK2MSFTNGP12.phx.gbl...
I currently have a set of documents in a directory that i need to list

in
a
html table. Is there any way to generate the table with the documents

listed
instead of having to update the table manually everytime a new

document is added to the list.

Thanks
Ken



Jul 19 '05 #5

P: n/a
On Tue, 22 Jul 2003 10:36:25 -0500, "Ken" <kl*****@spamfreeingr.com>
wrote:
I currently have a set of documents in a directory that i need to list in a
html table. Is there any way to generate the table with the documents listed
instead of having to update the table manually everytime a new document is
added to the list.


Here's how we serve up files from a folder dynamically:

<%
dim StringLength
dim TemporaryName
dim DisplayName
dirtowalk="/documents"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(server.mappath(dirtowalk))
Set fc = f.Files
response.write "<UL>"
For Each FileName in fc
StringLength = Len(FileName.name)
StringLength = StringLength - 4
TemporaryName = Left(FileName.name,StringLength)
DisplayName = Replace(TemporaryName,"_"," ")
response.write "<LI><A HREF='/documents/"
response.write FileName.name
response.write "'>"
response.write DisplayName
response.write "</A><br>"
Next
response.write "</UL>"
%>

No table, just a list of files without extensions, automatically
linked to the files. We normally publish in PDF format, try this link
for the end result:

http://manager.naplesgov.com/updates/2003.asp

I use this snippet quite a few places to serve up a list of documents
dynamically, but don't blame me for the code. I picked it up quite a
while ago and I'd credit the original author if I knew who it was.
Though I'm the one to blame for making the display pretty. :)

The code displays the file name, replacing underscores with spaces.
So we put the files to be served in the folder like this:

This_is_a_file.pdf
Here_is_Another.pdf

And so on. Adding table code into the loop isn't hard, something
like:

<%
dim StringLength
dim TemporaryName
dim DisplayName
dirtowalk="/documents"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(server.mappath(dirtowalk))
Set fc = f.Files
response.write "<TABLE CELLPADDING=2>"
For Each FileName in fc
StringLength = Len(FileName.name)
StringLength = StringLength - 4
TemporaryName = Left(FileName.name,StringLength)
DisplayName = Replace(TemporaryName,"_"," ")
response.write "<TR><TD><A HREF='/documents/"
response.write FileName.name
response.write "'>"
response.write DisplayName
response.write "</A></TD></TR>"
Next
response.write "</TABLE>"
%>

Change the dirtowalk variable to whatever directory you'll be using as
well as the appropriate HREF path.

Hope it helps.

Jeff
Jul 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.