Intro: I'm trying to make a html application (.htm) to make some business calculations. The issue that comes is that I need to keep records of everything. First I found some visual basic scripts to read/write .mdb files, but that was too complicated for me since I have never worked with vbs. So, I decided to use javascript to read/write .csv file
This is the function I found for reading:
function displayClassList() {
var path="log.csv"
var fso = new ActiveXObject('Scripting.FileSystemObject'),
iStream=fso.OpenTextFile(path, 1, false);
document.getElementById("searchResults").innerHTML="";
while(!iStream.AtEndOfStream) {
var line=iStream.ReadLine();
document.getElementById("searchResults").innerHTML += line + "<br/>";
}
iStream.Close();
}
It works good.
The problem I have is when it comes to writing. I can not append text to a new line in the document. This is the script I got:
var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.CreateTextFile("./ClassList.csv", true);
s.WriteLine("helloworld");
s.Close();
}
The problem with this script is that it replaces all the existing text with "helloworld". What I want is to write "helloworld" in new line. Any solution for that?
Also, is there any way to edit a specific line, like replacing all text in line x?
Here are the scripts for download so that you can test them : http://ge.tt/7u5bDAV2/v/0