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

2
  • this is probably solve your problem stackoverflow.com/questions/38963096/… Commented Jun 6, 2021 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. nodejs.org/en/knowledge/file-system/… .. You cannot write to a file using a script ran in the browser or in the client side for security reasons. Commented Jun 7, 2021 at 5:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.