title: Writing Data to CSV File using JavaScript
body: <p>I would like to write the data results from a form to the csv (or excel). I want to save this results in the server serverless (without php, etc.).</p>
  
  <p>I have found this code:</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
    &lt;script language="javascript"&gt;
      function WriteToFile(passForm) {
        var fso = new ActiveXObject("Scripting.FileSystemObject");
        var fileLoc = "C:\\sample.csv";
        var file = fso.CreateTextFile(fileLoc, true);
        file.writeline(passForm.FirstName.value + ',' +
                       passForm.LastName.value);
        file.Close();
        alert('File created successfully at location: ' + fileLoc);
       }
    &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
    &lt;p&gt;create a csv file with following details -&lt;/p&gt;
    &lt;form&gt;
      Type your first name: &lt;input type="text" name="FirstName" size="20"&gt;
  
      Type your last name: &lt;input type="text" name="LastName" size="20"&gt;
  
      &lt;input type="button" value="submit" onclick="WriteToFile(this.form)"&gt;
    &lt;/form&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  &lt;/br&gt;&lt;/br&gt;&lt;/html&gt;
  </code></pre>
  
  <p>But it does work only with IE.</p>
  
  <p>How to solve this problem?</p>
  
  <p>Regards</p>