title: JavaScript: Save HTML form and checkbox data to .txt file without server?
body: <p>I have an HTML form with text and checkbox inputs, and I want to to download this form data to a text file when I submit the form.  </p>
  
  <p>I <a href="https://stackoverflow.com/questions/13685263/can-i-save-input-from-form-to-txt-in-html-using-javascript-jquery-and-then-us">found a solution to download data from a textbox</a> into a text file, but I don't know how to modify it for the additional text and checkbox inputs that I require.</p>
  
  <p>Here is my current code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
      &lt;head&gt;
          &lt;script language="Javascript"&gt;
              function download(filename, text) {
                  var pom = document.createElement('a');
                  pom.setAttribute('href', 'data:text/plain;charset=utf-8,' +
                      encodeURIComponent(Notes));
                  pom.setAttribute('download', filename);
                  pom.style.display = 'none';
                  document.body.appendChild(pom);
                  pom.click();
                  document.body.removeChild(pom);
              }
              function addTextTXT() {
                  document.addtext.name.value = document.addtext.name.value + ".txt"
              }
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;form name="addtext" onsubmit="download(this['name'].value, this[’Notes’].value)"&gt;
              Notes:&lt;input type="text" name=“Note/Users/karlahaiat/Desktop/Copia de checklist.htmls”&gt;&lt;br&gt;
              Initials:&lt;input type="text" name=“Initials”&gt;&lt;br&gt;
              &lt;input type="checkbox" name=“check_list[]” value=“Check General Health”&gt;
              &lt;b&gt;Check General Health.&lt;/b&gt;&lt;br&gt;
              &lt;input type="checkbox" name=“check_list[]” value=“Check Fluid”&gt;
              &lt;b&gt;Check Fluid.&lt;/b&gt;&lt;br&gt;
              &lt;input type="text" name="name" value="" placeholder="File Name"&gt;
              &lt;input type="submit" onClick="addTexttxt();" value="Save As TXT"&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>The form above shows the input fields I want in my form however the text file won't download. Any help understanding the syntax would be great!</p>