title: Saving the output of a form to a text file via jQuery/Javascript posting to a php file?
body: <p>I've got a simple html form that as you can see below has been pre-filled with information for example purposes.</p>
  
  <p><img src="https://i.stack.imgur.com/pwwPv.png" alt="Example form"></p>
  
  <p>Currently when you click submit the form will be saved to Google Docs which works perfectly.</p>
  
  <p><strong>However</strong> I also want it to <em>log/save</em> the form output to a text file on the server where the page will be hosted.</p>
  
  <h3>Example Pre-Filled Form: <a href="http://jsfiddle.net/owcnwfhp/" rel="nofollow noreferrer">http://jsfiddle.net/owcnwfhp/</a></h3>
  
  <p>The format I am wanting it to be logged/saved as is shown below, each new line is a new form submission.</p>
  
  <h3>Example Expected Output:</h3>
  
  <pre><code>3/18/2015 8:06:27   testname    test4   test2   test3   test4   test5   test6   test7   test8   test9   test10
  3/18/2015 8:07:07   testname1   test4   test4   test3   test4   test5   test6   test7   test8   test9   test10
  3/18/2015 8:08:01   testname2   test2   test2   test3   test4   test5   test6   test7   test8   test9   test10
  3/18/2015 8:09:41   testname3   test2   test5   test3   test4   test1   test6   test7   test8   test9   test10
  </code></pre>
  
  <p><strong>The separating character must be an <em>ASCII tab character</em></strong></p>
  
  <p>I need to be able to make the logging/saving <strong>queue</strong> itself so that if two people used the form at once that there isn't a conflict and only one of the form submissions gets logged/saved.</p>
  
  <p><strong><em>I think</em></strong> the best location for the capturing/logging/saving of the form would be at the start of the function below that fires once the form has been submitted to Google docs.</p>
  
  <pre><code>function breakRedirect() {
      $('#container').replaceWith('&lt;div id="complete"&gt;Completed&lt;/div&gt;');
  };
  </code></pre>
  
  <h1>Function so far...</h1>
  
  <p>This is what I have so far, it's in the right format (sure the javascript/jquery might be a bit wrong but it works), I now need to find a way to be able to <strong>post it to a php script?</strong> So that It queues and writes to a file...</p>
  
  <pre><code>function breakRedirect() {
  
      var month = new Array();
          month[0] = "01"; month[1] = "02"; month[2] = "03"; month[3] = "04"; month[4] = "05"; month[5] = "06"; month[6] = "07"; month[7] = "08"; month[8] = "09"; month[9] = "10"; month[10] = "11"; month[11] = "12";
      var collection = new Date().getDate() + "/" + month[new Date().getMonth()] + "/" + new Date().getFullYear() + " "+ new Date().getHours() + ":" + new Date().getMinutes() + ":" + new Date().getSeconds();
  
      var $inputs = $("input")
      $inputs.each(function () {
          var value = this.value;
          if (value != "Submit Selections" &amp;&amp; value != "Clear Selections") {
              collection += "\t" + value
          };
      });
  
      var $selects = $("select")
      $selects.each(function () {
          var value = this.value;
          collection += "\t" + value
      });
  
      console.log(collection);
  
      $('#container').replaceWith('&lt;div id="complete"&gt;Completed&lt;/div&gt;');
  };
  </code></pre>
  
  <h1>Updated Fiddle: <a href="http://jsfiddle.net/owcnwfhp/1/" rel="nofollow noreferrer">http://jsfiddle.net/owcnwfhp/1/</a></h1>
  
  <p>Any ideas?</p>