Solved

Dynamically loading a text box from a text file using VBScript

Posted on 2004-03-31
5
156 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now