OK, I’ve just spent the last half day look for and researching how to do this
with javascript, and although I have found many examples that come very
close to what I need, most are over powered examples, and are not as simple
as I need.
I also now have a scrambled brain from reading so much and am getting lost
more so now than earlier.
Here’s what I need, and should be extremely simple for an experienced
javascript coder…
I need code (javascript) that will open a txt file, read in the contents of that
file, then place the contents from that file into a textarea of my web form.
The reason I am using javascript instead of php is because I have to use this
form on a Windows desktop and not on a server. So, javascript has got to be
my answer for this one.
Could someone kindly give me a simple example of how I can get this job
done so I can get on with the rest of this project that should have been
finished hours ago?
the method that it uses to get the info is an iframe that is hidden, that iframe must be on the same domain as the txt file
if you are trying to access the stuff on a users computer, you are a bit SOL unless you are willing to use ActiveX or have the user upload the file themselves.
I’ve got this code so far I’ve been building up throughout the day from
various tutorials and so forth, and in fact, this code would work perfect for
me if I could only figure out how to get it to read the entire file, instead of
only the first line of the file.
Can someone please take a look at my code, and tell me what I need to
change to get this to read the entire file into my variable and not just the
first line?
Here it is:
var filename = 'temp.htm';
var fso, a, ForReading, sContent;
ForReading = 1;
fso = new ActiveXObject('Scripting.FileSystemObject');
file = fso.OpenTextFile(filename, ForReading, false);
sContent = file.readline();
file.Close();