Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Dynamically loading a text box from a text file using VBScript

Posted on 2004-03-31
5
Medium Priority
?
166 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 1000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

916 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