-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathform.js
32 lines (28 loc) · 822 Bytes
/
form.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const whatisyourname = document.querySelector(".whatisyourname");
const calenderName = document.querySelector(".calendar_name");
const form_js = document.querySelector(".form_js");
const form = form_js.querySelector("form");
const input = form.querySelector("input");
function loadName() {
const currentUser = localStorage.getItem("currentUser");
if (currentUser) {
} else {
askForName();
whatisyourname.classList.remove("hidden");
}
const currentUserName = localStorage.getItem("currentUser");
calenderName.textContent = `Hi ${currentUserName}`;
}
function submitName() {
const currentValue = input.value;
localStorage.setItem("currentUser", currentValue);
}
function askForName() {
form.addEventListener("submit", () => {
submitName();
});
}
function init() {
loadName();
}
init();