the problem to push data into localstorage from the array with objects, the details getted through textboxes by registeration and login
how json used for this problem in javascript
<body background="img.jpeg">
<div><dr><a href="logon.html">LOGIN</a> <a class="a1" href="register.html">REGISTER</a></dr> </div>
<div class="div1">
<form id="log">
<h1>LOGIN</h1>
<label><b>USERNAME:</b></label><input type="text" name="Username" id="usrnme"><br><br>
<label><b>PASSWORD:</b></label><input type="text" name="Password" id="pwd"><br><br>
<label><b>EMAIL-ID:</b></label><input type="text" name="Email" id="mail"><br><br>
<input type="button" value="Register" name="Register" onclick="register()">
</form>
</div>
the result to store the data to the local storage
Basically you can store data with two ways.
You can use the setItem function
localStorage.setItem(myKey, myValue);
or you can directly set those values via
localStorage.myKey = myValue;
If you want to receive values from the localstorage you can use get instead of set.
Please let me know if that already helps you.
You can use, FormData,
<script>
let frm = document.querySelector("#log");
let data = new FormData(frm);
for (var [key, value] of data.entries()) {
localStorage.setItem(key, value);
}
// Finally you can get values from localStorage
localStorage.getItem("key");
</script>
Before run this code make sure form values are not empty.
You need to create a JS file or <script>
tag that can extract the values from the input field and use browser localstorage
API to set the values.
Seeing that your code is still limited to just HTML and I do not know your level of knowledge in HTML and JS, I will add a code snippet to help you along the way:
...html stuff
<script>
// JS code
</script>
Resources:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.