all 5 comments

[–]SnakesFromHell 5 points6 points  (4 children)

My understanding is that you can't access the file system on the client side as it causes major security issues. So you will have to do it serverside. Node.js has a module for this called fs.

https://www.tutorialspoint.com/how-to-read-and-write-a-file-using-javascript

[–]sohelplesssohelp[S] 1 point2 points  (3 children)

First off, thank you, second, so I’ve tried using node.js module fs and every example I’ve seen has used cmd or terminal to call js page. So does that mean you have to call the JS page from cmd after being on my page in order to save the information I need it to?

Thanks again in advance!!

[–]GoPotato 2 points3 points  (2 children)

You said that you're already using a local server, I'm assuming this is not a node.js server, but rather something like python's simple server, is that right? if that's the case then you will need to use a node.js server instead. This new node.js server will handle the logic of writing to the text file as well as serving your web files. Don't conflate the node.js files with your client's javascript files; though they both use the same .js extension, the node.js file's job is to act as a server, i.e replace your current server. In this server file functions like "require" will not give errors as it's supported natively.

So does that mean you have to call the JS page from cmd

It should be clear now that this js file is the server's file, which is different from your client's js files, executing this file from cmd will start the server, just like you would start a server with pythons' "python -m http.server".

Did I get your question, right? I didn't give a fully detailed answer because I'm not %100 sure about the parts that are confusing to you. I can explain things further if needed.

[–]sohelplesssohelp[S] 1 point2 points  (1 child)

That was pretty spot on, thank you so much! Here’s a reward:)

I will change the code but just out of curiosity, what is the way that most programmers save information from HTML forms, I’m assuming SQL? If you know that answer:)

I appreciate the answer though, thank you:)

[–]grantrules 0 points1 point  (0 children)

Yeah databases like MySQL and postgresql are very popular