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!

capture the name of the link in a variable 2

Status
Not open for further replies.

PaulBricker

Programmer
Sep 25, 2002
3,554
US
I have an asp page that takes the names of all the files in a Folder and creates a link to them so users can open the files. Now I have a little wrinkle. They decided to store all the files in subfolders. I changed my original code so I can open all the subfolders as links, but now I need to capture the name of the subfolder link that is clicked so I can display the files in those subfolders as links. I know I could write an asp page for each subfolder and put the physical path to each subfolder in, but I'd like to write one asp page and pass the name of the subfolder link clicked to the page. Is there any way to do this? Here is the relevent code I'm using to get my files.
<%
Dim fso, f, files
Dim i
i = 0
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("E:/WEBSITE/businessOffice/BudgetReports/subfolderNameHere")
set files=f.Files
%><div id = "content"><%
for each file in files

If i mod 3 = 0 Then
Response.Write "<p><a href=" & Chr(34) & "subfolderNameHere" & file.Name & Chr(34) & "></p>"
Response.Write file.Name & "</a> &nbsp; &nbsp; &nbsp"
Else
Response.Write "<a href=" & Chr(34) & "subfolderNameHere" & file.Name & Chr(34) & ">"
Response.Write file.Name & "</a> &nbsp; &nbsp; &nbsp"
End If
i = i+1
next
%></div><%
Set objFolder = Nothing
Set objFSO = Nothing

%>



Thanks

Paul
 
Check out this thread frm earlier in the week. I wrote a simple script to allow users to go through subfolders and folders that maks everything links and controls it all from a single location. You can use it as an example or maybe even just modify it to fit your needs. thread333-820543

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
I've done some small changes to make it show the directory structure and navigate throu it.
Code:
index.asp


<%
 Dim fso, f, files 
 Dim i
 i = 0
Set fso = Server.CreateObject("Scripting.FileSystemObject") 
rootFolder=Server.MapPath(".")
curentFolder=rootFolder+"/"&Request("folder")
Set f = fso.GetFolder(curentFolder) 
set files=f.Files
set folders=f.SubFolders

%>
<div id = "content">
<%
for each folder in folders
Response.Write "<p><a href=index.asp?folder="&Request("folder")&"/" & folder.Name&"></p>"
Response.Write Ucase(folder.Name) & "</a> &nbsp; &nbsp; &nbsp"
next
%>
</div>
<div>
<%
for each file in files

If i mod 3 = 0 Then
Response.Write "<p><a href=" & Chr(34) & "[URL unfurl="true"]http://businessoffice.williston.com/BudgetReports/subfolderNameHere"[/URL] & file.Name & Chr(34) & "></p>"
Response.Write file.Name & "</a> &nbsp; &nbsp; &nbsp"
Else
Response.Write "<a href=" & Chr(34) & "[URL unfurl="true"]http://businessoffice.williston.com/BudgetReports/subfolderNameHere"[/URL] & file.Name & Chr(34) & ">"
Response.Write file.Name & "</a> &nbsp; &nbsp; &nbsp"
End If
i = i+1
next
%>
</div>

________
George, M
Searches(faq333-4906),Carts(faq333-4911)
 
Thanks everyone. I'm going into a meeting in 5 minutes to get ALL the changes. I will look this stuff over this weekend. I do appreciate it.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top