1

Im new to html and javascript but is there a way take input from html and save that data into a file named db.json. Any help would be appricated thanks.

Here is my input boxes code:

            <h2 style="color: white; text-align: center;">Username</h2>
            <input type="text" name="txtName" placeholder="Enter your username" />
            <h2 style="color: white;text-align: center;">Message</h2>
            <textarea id="msg" name="msg" placeholder="Write some message ..." style="height:100px"></textarea>
            <div></div>
            <button type="submit">Submit</button>

Hope this helps if you need more info please let me know. I do know its not the greatest idea to save to a json file

Bigdude68
  • 21
  • 6
  • this is probably solve your problem https://stackoverflow.com/questions/38963096/save-html-form-input-to-json-file – Ali Ehyaie Jun 06 '21 at 18:37
  • 1
    This is not possible unless you are using server side Javascript such as NodeJS where you have access to the OS environment including files and directories. If you are actually using Node, use the file system module to write to a file. https://nodejs.org/en/knowledge/file-system/how-to-write-files-in-nodejs/ .. You cannot write to a file using a script ran in the browser or in the client side for security reasons. – iismaell Jun 07 '21 at 05:04

0 Answers0