Javascript saves form output locally

New Here ,
May 04, 2018 May 04, 2018

Copy link to clipboard

Copied

Hi

Im looking for some help in creating an HTML form. Using DW CC 2018 I have made a very simple form with 5 checkboxes. I want to  save the output when submitted to a text file, ideally using a filename generated from the date. Can this be done without creating a php file. I don't want it stored on a server it is being entered and hopefully saved on a standalone PC. Any help would be appreciated, I'm OK with HTML and a beginner with JS (which I think is the way to do it)

TOPICS
Acrobat SDK and JavaScript

Views

88

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
May 04, 2018 May 04, 2018

Copy link to clipboard

Copied

This is the Acrobat JavaScript forum, which has no connection to web browser JavaScript. Surely web browsers cannot save text files locally, though, that would be a horrendous security hole. When you submit it goes to a web browser (PHP, ASP, CGI etc.) written by an experienced web professional up to date with the latest security threats and tricks. Submit only means that, not a local action.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 04, 2018 May 04, 2018

Copy link to clipboard

Copied

Sorry - as stated I am a beginner.

Security is not really an issue as its a standalone PC (otherwise i would use PHP or ASP)

I was using this as a basis which works but I want to add more fields and if possible use a function to automatically name the file based on the date.....

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

  <head>

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

    <style>

form * {

  display: block;

  margin: 10px;

}

</style>

    <script language="Javascript">

function download(filename, text) {

  var pom = document.createElement('a');

  pom.setAttribute('href', 'data:text/plain;charset=utf-8,' +

encodeURIComponent(text));

  pom.setAttribute('download', filename);

  pom.style.display = 'none';

  document.body.appendChild(pom);

  pom.click();

  document.body.removeChild(pom);

}

</script>

    <title>Form_Test_Local</title>

  </head>

  <body>

    <form onsubmit="download(this['name'].value, this['text'].value)"> <input

        name="name" value="test.txt" type="text"> <textarea rows="3" cols="50" name="text">Please type in this box. When you

click the Download button, the contents of this box will be downloaded to

your machine at the location you specify. Pretty nifty. </textarea> <input value="Download" type="submit">

    </form>

  </body>

</html>

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines