I have written code for appending data to csv file using javascript but data is getting stored without header name in csv file. please find below my HTML and javascript code :
<html>
<head>
<script language="javascript">
function WriteToFile(passForm) {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fileLoc = "D:\\sample.csv";
var file = fso.OpenTextFile(fileLoc,8, true,0);
file.writeline(passForm.FirstName.value + ',' + passForm.LastName.value);
file.Close();
alert('File created successfully at location: ' + fileLoc);
}
</script>
</head>
<body>
<p>create a csv file with following details -</p>
<form>
Type your first name: <input type="text" name="FirstName" size="20">
Type your last name: <input type="text" name="LastName" size="20">
<input type="button" value="submit" onclick="WriteToFile(this.form)">
</form>
</body>
</html>
Now by using above code data is stored in csv without any header name (Column name) If i append new data to csv the header name should be entered only once at the time of file creation.
Kindly help me for the same. Thank you so much in advance.