const createAccBtn = document.getElementById('createAccBtn');
const logInBtn = document.getElementById('logInBtn');
createAccBtn.addEventListener("click",(event) => { userInput(true) });
logInBtn.addEventListener("click", (event) => { userInput(false) });
function userInput(newUser){
console.log("gfjkd");
const usernameinput = document.getElementById('usernameinput').value;
const passwordinput = document.getElementById('passwordinput').value;
console.log('Username:', usernameinput);
console.log('Password:', passwordinput);
var info = {
usernameinput: usernameinput,
passwordinput: passwordinput
}
if (newUser){
sock.emit("makeaccount",info);
}
else{
sock.emit("login",info);
}
}
#Problem reaching function
3 messages · Page 1 of 1 (latest)
userInput code works here
logInBtn is in index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input type="text" class="form-control" id="usernameinput" placeholder="Your message" name="textmessage">
<input type="password" class="form-control" id="passwordinput" placeholder="Your message" name="textmessage">
<button id="logInBtn">Log in</button>
<a href="static/register.html">No account? Click here to register</a>
<script src="https://cdn.socket.io/4.5.4/socket.io.min.js"></script>
<script type="module" src="static/game.js" ></script>
</body>
</html>
but userInput won't work. it won't even console.log. Why?
theres no createAccBtn