title: How to save user inputs of html form to a single csv file
body: <p>I am having a html form when the user submit the form it should save the file as csv and store and when the user again types/submits the form it should get updated in the same csv file.I have used the below code in which it creates a new csv file each time can anyone tell me how to do it.</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;
  &lt;head&gt;
      &lt;title&gt;Writing Data to CSV&lt;/title&gt;
      &lt;script type="text/javascript"&gt;
          function addToCSVFile() {
              var csvData = new Array();  // To collect the names
  
  
              // Collecting the names
              csvData[0] = document.getElementById('firstName').value;
              csvData[1] = document.getElementById('middleName').value;
              csvData[2] = document.getElementById('lastName').value;
  
              window.open('data:text/csv;charset=utf-8,' + csvData.join(','));
  
              clearData();
              alert("Data Added Successfully");
          }
  
          function clearData() {
              document.getElementById('firstName').value = "";
              document.getElementById('middleName').value = "";
              document.getElementById('lastName').value = "";
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;p&gt;
          First Name: &lt;input type="text" id="firstName" /&gt;
          &lt;br /&gt;
          Middle Name: &lt;input type="text" id="middleName" /&gt;
          &lt;br /&gt;
          Last Name: &lt;input type="text" id="lastName" /&gt;
          &lt;br /&gt;
          &lt;input type="button" id="addButton" value="Add to CSV File" onClick="javascript: addToCSVFile()" /&gt;
      &lt;/p&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>