Link to home
Start Free TrialLog in
Avatar of wrigha
wrighaFlag for Canada

asked on

Dynamically loading a text box from a text file using VBScript

Hi,

Just to be clear upfront... I am a total novice at this so please excuse my ignorance.

I am writing some utilities to replace some client side functions.
On one of them I need to load the contents of a list box from a text file which changes daily.
I have been directed to provide this solution in scripting only (VBS or Java Script, preferably VBS).

Please help.

Thanks.
Avatar of plq
plq
Flag of United Kingdom of Great Britain and Northern Ireland image

<%
set scr = server.createobject("scripting.filesystemobject")
set txt = scr.opentextfile(filename, false)
sBuffer= txt.ReadAll()
txt.close()
set scr = nothing

sSplit = Split(sBuffer, vbCRLF)

%>
<select size=20>
<%
for i = 1 to ubound(sSplit)
  Response.Write "<option value='" & sSplit(i) & "'>" & sSplit(i) & "</option>
next
%>
</select>


Avatar of wrigha

ASKER

Thanks for your reply.
Unfortuntely nothing happens.  Just an empty text box is shown.
Here is the html code:
<HTML>
<BODY>
<%
set scr = server.createobject("scripting.filesystemobject")
set txt = scr.opentextfile("users.txt",1,0)
sBuffer= txt.ReadAll()
msgbox(sbuffer)
txt.close()
set scr = nothing
sSplit = Split(sBuffer, vbCRLF)
%>

<select name="test" size=20>

<%
for i = 1 to ubound(sSplit)
  Response.Write "<option value='" & sSplit(i) & "'>" & sSplit(i) & "</option>"
next
%>
</select>

</BODY>
</HTML>


Thanks
ASKER CERTIFIED SOLUTION
Avatar of ramesh12
ramesh12

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial