I was making a new service-based website and I created the contact form. When I put my info and submit it, the website refreshes but I don't know where that information goes. I want to be able to store it somewhere, like .txt or something. Thanks in advance. (I use JS).
<form action="">
<h3>get in touch</h3>
<input type="text" placeholder="your name" class="box" />
<input type="email" placeholder="your email" class="box" />
<input type="tel" placeholder="subject" class="box" />
<textarea
placeholder="your message"
class="box"
cols="30"
rows="10"
></textarea>
<input onclick="alert('Thanks For Your Response')" type="submit" value="send message" class="btn" />
<span>OR</span>
<a
class="btn"
href="tel:9724005492"
>Call Now</a
>
</form>
It goes to the URL specified in the action attribute.
The expectation is that you will have some server-side code ready (at that URL) to receive the data and process it.
MDN has a guide to sending and retrieving form data which covers how it works and has examples for a few programming languages.
You said you were using JS. If you are using server-side JS, then it is common to use Express.js, in which case you can set up a body parsing middleware and then read the data from req.body. You can then store it somewhere, which could be a text file, but it is more usual to use a database (which would handle race conditions if you ended up with simultaneous inserts).
MDN has a Working With Forms section in their Express.js tutorial
Client-side JS can't store the data anywhere that is particularly useful for the developer of the website, but you can add an event listener for the form element's submit event and then process the data on the client. There are a few places you could store it on the client (e.g. local storage) but that will stay with the browser and not get to the person running the website.
Client-side JS could also make its own HTTP request (i.e. Ajax) to a server-side program which processes the data. The net result is the same as submitting the form to one though, just with more control over the UI.