Hi! I want to save my HTML form to a certain file in my computer. and whenever I click on submit, I want the file to get updated. and later I want to fetch the file data group wise. is this possible by using JS, AJAX, JSON only?
This is my local html file .
<aside id="sidebar">
<div class="dark">
<h3> Get a Quote</h3>
<form class="quote" id="contactForm" method="POST" action="/contact">
<div>
<label>Name</label><br>
<input type="text" name="Name" id="person">
</div>
<div>
<label>Email</label><br>
<input type="email" name="Email Address" id="email">
</div>
<div>
<label>Message</label><br>
<textarea placeholder="Message" name="query"></textarea>
</div>
<input type="submit" value="Send">
</form>
</div>
Iam running localhost server by using node.js. Now, when I click on submit, I want the form input to be stored in the certain folder[for example C:\Users..] in JSON format like an array. For example, the file may look like
[
{ "person": "abc",
"email": "123@mail.com",
"message": "abcdefg",
},
{ "person": "efg",
"email": "456@mail.com",
"message": "bcdefg",
},
]
So when ever i am clicking on submit button the file should automatically get updated and save the next input as an array.
The second part is, fetching the store input value from recent to old when clicking on the button. so basically the second part would contain a basic HTML page with a button. and when I click on the button, it should show me the recent group of an array which is stored, for us from the above example the first click should show
{ "person": "efg", "email": "456@mail.com", "message": "bcdefg", },
and the next click should show
{ "person": "efg", "email": "456@mail.com", "message": "bcdefg", },
{ "person": "abc", "email": "123@mail.com", "message": "abcdefg", },
so basically in a decreasing order. and want to solve using AJAX. The first part is saving file input by use of JS, DOM, JSON. The second part is fetching file data AJAX. at present I do not want to use PHP, or ASP or any local browser storage, or online data base.
What I have tried:
I came across many forums, and I am getting confused, Suggest me regarding the codes and how to solve it. i know the second part, but I cannot able to do the first part.