Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

read a text file display values in drop down menu

 
cara dastoli
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two problems. The first one is I am trying to read a text file and display values in a drop down menu on a form. The file is a simple file with fields seperated by commas. I got as far as reading the file, parsing it and displaying the fields in individual text files but I can't figure out how to display them in a drop down.

The second part of my problem is that I can only read and display the values in IE and not Firefox. Any help with the coding on both of these issues is appreciated.

Thanks,

Cara
[ May 22, 2007: Message edited by: cara dastoli ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Showing code really helps.

You need to look into

new Option(text,value)

to add the elements to the select.

Eric
 
cara dastoli
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eric Pascarello:
Showing code really helps.

You need to look into

new Option(text,value)

to add the elements to the select.

Eric
 
cara dastoli
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eric Pascarello:
Showing code really helps.

You need to look into

new Option(text,value)

to add the elements to the select.

Eric


Thanks for the info. Here is the original code, it doesn't work with Firefox:


<script language = "javascript">

<!-- Begin/

function GetUni(input)
{
computeForm(input.form);
}


function computeForm(form)
{

objXml = new ActiveXObject("Microsoft.XMLHTTP");

// objXml = new ActiveXObject("Msxml2.XMLHTTP"); older version
var datafile = "myfile.txt";

objXml.open("GET", datafile, true);
objXml.onreadystatechange=function() {
if (objXml.readyState==4) {
display(objXml.responseText);

}
}

objXml.send(null);

function display(msg) {
var t1 = msg;
alert ("test t1: " + t1);
form.outputuni.value = t1;


var string = msg.substring(0,120);
var separator = ',';
var stringArray = string.split(separator);
for (var i=0; i < stringArray.length; i++)
var counter = i + 1;
var v1 = (stringArray[0] + " ");
var v2 = (stringArray[1] + " ");
var v3 = (stringArray[2] + " ");
var v4 = (stringArray[3] + " ");
var v5 = (stringArray[4] + " ");
var v6 = (stringArray[5] + " ");
var v7 = (stringArray[6] + " ");
var v8 = (stringArray[7] + " ");
var v9 = (stringArray[8] + " ");
var v10 = (stringArray[9] + " ");


form.uni1.value = v1;
form.uni2.value = v2;
form.uni3.value = v3;
form.uni4.value = v4;
form.uni5.value = v5;
form.uni6.value = v6;
form.uni7.value = v7;
form.uni8.value = v8;
form.uni9.value = v9;
form.uni10.value = v10;

}

}
// End -->
</script>

<input type="text" size="10" name="uni1"><br>
<input type="text" size="10" name="uni2"><br>
<input type="text" size="10" name="uni4"><br>
<input type="text" size="10" name="uni3"><br>
and so on through "uni10".

I just want these text boxes to be a drop down menu.
Otherwise, it works fine except for the Firefox issue.

Thanks Again.

Cara
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ActiveX = IE only

http://developer.apple.com/internet/webcontent/xmlhttpreq.html

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic