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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List/Menu Populate from file structure

Status
Not open for further replies.

huobaji

Technical User
Sep 20, 2010
23
US
hello

Is there a way for a listmenu to read a file structure and list the contents in the folder. Does anyone have a sample code.

Thanks in advance
 
Code:
<%
cFolderPad = "e:/inetpub/[URL unfurl="true"]wwwroot/myfolder"[/URL]

dim aBijlage, i
redim aBijlage(100)
i = 0

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder( cFolderpad )
For Each objItem In objFolder.Files
  aBijlage(i) = objItem.Name
  i = i + 1
Next

Set objItem = Nothing
Set objFolder = Nothing
Set objFSO = Nothing

redim preserve aBijlage(i)
%>
<select name="fBijlage">
<%
 for n=0 to i-1
   response.Write "<option value='" & aBijlage(n) & "'"
   response.Write ">" & aBijlage(n)
 next
 %>
</select>
 
I decided to use a textarea to display the values. However its putting this in the text area: <option value='" with the value I want.

Do you know why that is?


%>
<textarea name="fBijlage" cols="25" rows="35">
<%
for n=0 to i-1
response.Write "<option value='" & aBijlage(n) & "'"
response.Write ">" & aBijlage(n)
next
%>
</textarea>
</p>
 
change it into:
Code:
<% for n=0 to i-1   
response.Write aBijlage(n) & vbCrLf
next 
%>

 
That worked great. Thanks

One question why would the first value have space before the value

example

text value
text value
text value
 
I have another question: Is there a way to link the values to the physical file. and open the file and read it? these files are XML files.

Im using Server.CreateObject("Microsoft.XMLDOM") to read the XML file.


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="trans.css" rel="stylesheet" type="text/css" />
</head>

<body>
<p>
<%
dim fs,fo,x
dim aBijlage, i, url
cFolderPad = (Server.MapPath("/secure/XML"))

redim aBijlage(100)
i = 0

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder( cFolderpad )
For Each objItem In objFolder.Files
aBijlage(i) = objItem.Name
i = i + 1
Next

Set objItem = Nothing
Set objFolder = Nothing
Set objFSO = Nothing

redim preserve aBijlage(i)

%>
<p><strong>XML
</strong>

<p>
<textarea name="fBijlage" class="trans" cols="29" rows="30">
<%
response.Write "Select File" & vbCrLf & vbCrLf
for n=0 to i-1

response.Write ">"& aBijlage(n) & vbCrLf
next
%>
</textarea>
<p>&nbsp;</p>
</body>
</html>
 
why in a textarea? that's an INPUT field.
list the files as links:
Code:
<strong>XML </strong> 
<%  
response.Write "Select File: <br>"
for n=0 to i-1   
response.Write "<a target=""_blank"" href=""/secure/XML/" & aBijlage(n) & """>" & aBijlage(n) & "</a></br>" 
next 
%>
 
There might be a lot of files so I might need to scroll through the list. Instead of scrolling down the page.

Is there a better option?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top