Solved

Dynamically loading a text box from a text file using VBScript

Posted on 2004-03-31
5
161 Views
Last Modified: 2010-04-06
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.
0
Comment
Question by:wrigha
5 Comments
 
LVL 8

Expert Comment

by:plq
ID: 10730524
<%
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>


0
 

Author Comment

by:wrigha
ID: 10734284
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
0
 
LVL 7

Accepted Solution

by:
ramesh12 earned 250 total points
ID: 10742319
It seems you are saving your file with htm(l) extension. That code is for ASP

Here have a look at this. It has an accepted answer using javascript

http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20837002.html
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question