Remote filesystemobject (2nd try)

M

Malcolm

I am a near total novice, trying to write some Javascript code that will
display certain elements in a comma separated value file (gifts.csv) in
tabular form when a page is loaded. I have come up with the following which
works fine when I view the page in my coding tool (AceHTML 5 Pro). Basically
it sets up an array, opens the csv file, reads each line from the file,
decides whether the line needs processing and if so loads each value into an
element of the array and writes some of them out. There are some table tags
thrown into appropriate places.

<script>

information = new Array(10);
y = new ActiveXObject("Scripting.FileSystemObject");
gift = y.opentextfile("gifts.csv",1);
x = document.write("<table>");

do {
x = document.write("<tr>");
giftinfo = gift.readline();

if (giftinfo.charAt(0)=="0") {
information = giftinfo.split(",");
x = document.write("<td>",information[4],"</td>");
x = document.write("<td>",information[5],"</td>");
x = document.write("<td>",information[9],"</td>");
x = document.write("</tr>");
}
}
while (!gift.AtEndOfStream);

x = document.write("</table>");

</script>

However it doesn't work from a server using IE. From what I've read I
believe it is because the filesystemobject works with the local filesystem
whereas the csv file is on the server.

Is there any way of redoing this so that the file on the server is opened
and read, or can I download the csv file onto the client machine so that it
works as written, or do I need to be doing something with asp (is that
right?) so the the scripting runs on the server not the client?

Or am I asking the wrong questions?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top