Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
How to save form data in div to a text file using HTML and Javascript

So currently I have an HTML page where the user completes some data entry. Their data is spanned into a form on the page which they then copy and paste into a text file. I would like to include a button that would simply take the form, along with the spanned data, and save it to a text file. This will all be done locally, the user will have the HTML file saved on their computer. I have tried doing this via a textarea and a div but in both cases the text file doesn't include the actual user data but just the HTML code. Here as example of how the program works:

function example(){
   var elements = document.querySelectorAll(".showexample");
   for(var i = 0; i<elements.length; i++){
      elements[i].innerHTML = document.querySelector(".exampleinput").value;
   }
}

<TD><input type="text" class="exampleinput" oninput="example()"></TD>

<div id="forUserDownload">
your input:<span class='showexample'></span>
</div>

When I try to include a download function (such as the one here:https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/), it just shows the HTML code instead of the actual user input. Is there anyway to do this with only HTML and Javascript?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!