Solved

Dynamically loading a text box from a text file using VBScript

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
error email attachment VB2010 5 39
wordpress limitations 4 115
replace quotes with UTF-8 character 38 96
Questions about this React unit test 4 62
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…
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
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:
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

773 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