Create Drop down from txt fle

N

noone

Is there a way to create a drop-down on the fly from an external text file
and use that drop-drop down in an html or asp page?

Thanks
 
S

Steve Easton

What kind of drop down??
Drop down select box, or a jump menu.


--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
N

noone

Select box
Steve Easton said:
What kind of drop down??
Drop down select box, or a jump menu.


--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
.......................with a computer
 
S

Steve Easton

It could be done, with some pretty heavy scripting. Server side preferably.
Which means asp or php.
What exactly are you trying to do??


--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
N

noone

I think I got it, this reads each line of a deliminted file in a drop down.
----------------------------------------------------------------------------------------
<%@ LANGUAGE = "VBScript" %>
<%Option Explicit

'Declare the variables that are important to us
Dim fsoList, tsList
Dim strFilePath
'Find the local path to the file we want. Sort of assumes it in the same
directory as the script
strFilePath = Server.MapPath("list.txt")

Response.Write "<html><body>" &VBCrLf


'Open the File System Object, check for the file, open the file, prepare the
file for reading
Set fsoList = Server.CreateObject("Scripting.FileSystemObject")
If fsoList.FileExists(strFilePath) Then
'Start the select box
Response.Write "<br><center><select>" &VBCrLf
'Open a stream from the file
Set tsList = fsoList.OpenTextFile(strFilePath)
'Read the file and put the contents of a line in between option tags
Do Until tsList.AtEndOfStream
Response.Write "<option>"&tsList.ReadLine&"</option>" &VBCrLf
Loop
'Clean up after ourselves
tsList.Close : Set tsList = Nothing
'Close the Select box
Response.Write "</select>" &VBCrLf
Else
Response.Write strFilePath & " does not exist"
End If
Set fsoList = Nothing


Response.Write "</body></html>" &VBCrLf
%>
 
S

Steve Easton

That will work, "providing" that the visitor hasn't disabled Windows
Scripting Host on their machine.

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top