Click to See Complete Forum and Search --> : Please Help...fill ListBox with .txt


Labyrinet
07-14-2003, 02:56 PM
Here's my HTML Code

<HTML>
<HEAD>
<TITLE>Data</TITLE>
<SCRIPT LANGUAGE="JavaScript">
</SCRIPT>
</HEAD>
<SELECT NAME="#Fruit" onLoad="VALUE="Fruit" size="1"></SELECT>

<TABLE DATASRC="#Fruit" BORDER=1 ALIGN="center">
<THEAD STYLE="background-color:yellow; text-align:center">
<TR><TD>Fruit</TD>
</TR>
</THEAD>
<TR>
<TD><DIV ID="col1" DATAFLD="Fruit" ></DIV></TD>

</TR>
</TABLE>
<OBJECT ID="Fruit" CLASSID="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
<PARAM NAME="DataURL" VALUE="DropDown.txt">
<PARAM NAME="UseHeader" VALUE="True">
<PARAM NAME="FieldDelim" VALUE=" ">
</OBJECT>
</HTML>



Here's the conents of my .txt file

Fruit
Apples
Oranges
Bananas
Grapes

It works fine in a table but can anyone help me make the .txt file contents appear in a dropdown listbox?

I'm very new to js and this is driving me crazy.

Thank You,
Labyrinet

olerag
07-14-2003, 03:19 PM
Are you sure you need Javascript - this appears to be several HTML keywords.

<form>
<select name=fruit size="5" multiple>
<option value="1">Apples</option>
<option value="2">Lemons</option>
<option value="3">Strawberrys</option>
<option value="4">Peaches</option>
<option value="5">Grapefruit</option>
</select>
</form>

Am I missing something or are you really asking about extracting data from a text file into an html file??

Labyrinet
07-14-2003, 03:27 PM
I write multi-user software the app runs a box running IIS I can write files (any file ext...) to that box so basically if I can get my HTML page to read the files, my clients can manipulate what appears to there customers in the dropdowns. I want to dynamically change the .txt not the html code...

brendandonhue
07-14-2003, 04:13 PM
Client-side javascript can not write to files or read anything except .js files.

Labyrinet
07-14-2003, 05:38 PM
Even if the/an ActiveX control was on the IIS box?

brendandonhue
07-14-2003, 06:33 PM
I dont know about your ActiveX controls-all I know is javascript or html can't do anything with text files.

Exuro
07-14-2003, 08:33 PM
The easiest way to do this, in my opinion at least, would be to use some server-side-scripting. But I doubt you have that option... Next best thing I can think of is to use XML. You can read data from a .xml document into your page using JavaScript, kind of like what you were doing with your text file. You can read about it at the W3School's website:

http://www.w3schools.com/xml/default.asp

But, if you don't want to read the whole thing, here's something I came up with for you. First, you need a file called fruits.xml with the following contents:

<fruits>
<fruit>Apples</fruit>
<fruit>Lemons</fruit>
<fruit>Strawberrys</fruit>
<fruit>Peaches</fruit>
<fruit>Grapefruit</fruit>
</fruits>


After you've created that file, use the code from the document I attached to this message in order to read the data from the XML document into your Select element. The only downside is that it doesn't have very good cross-browser support... Hope that helped!

Labyrinet
07-15-2003, 09:06 AM
Thank You!!! Excellent solution, just what I was looking for. I had read similar article but just didn't have the skill to pull it off. Also, Thanks to all who took the time to respond.