I have this Javascript code.
var navButton = document.getElementById("nav-button");
let outerlogouttrigger = false;
var email = document.getElementById("Email").value;
var password = document.getElementById("password").value;
document.getElementById("Login").onclick = function() {
loginfunction()
};
function loginfunction() {
sessionStorage.setItem('isLoggedin', 'true');
//This is for making the changes instanteniously after clicking
if (sessionStorage.getItem('isLoggedin') === 'true') {
navButton.innerHTML = "Log out";
navButton.classList.remove("btn-warning");
navButton.classList.add("btn-success");
outerlogouttrigger = !outerlogouttrigger; //not woring
}
}
console.log(outerlogouttrigger);
console.log(email);
console.log(password);
// This if comes in effect after refresh
if (sessionStorage.getItem('isLoggedin') === 'true') {
navButton.innerHTML = "Log out";
navButton.classList.remove("btn-warning");
navButton.classList.add("btn-success");
}
I have 2 questions:
- How to change the
outerlogouttrigger
value which is not changing in my case. - how to get the value of the
email
andpassword
which is taken input in a html form. The input type ofemail
is email and input type ofpassword
is password. I want to check if they are empty or not!