We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9574d1d commit 7511a07Copy full SHA for 7511a07
formScript.js
@@ -0,0 +1,18 @@
1
+function storeData(e) {
2
+ e.preventDefault(); // prevent default form submission
3
+
4
+ const formData = new FormData(form);
5
+ const userData = {};
6
7
+ // iterate over the form fields and store their values in the userData object
8
+ formData.forEach((value, key) => {
9
+ userData[key] = value;
10
+ });
11
12
+ // store the userData object in localStorage
13
+ localStorage.setItem("userData", JSON.stringify(userData));
14
+}
15
+const storedData = localStorage.getItem("userData");
16
+const userData = JSON.parse(storedData);
17
18
+console.log(userData);
0 commit comments