Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search


  • Content Count

  • Joined

  • Last visited

  1. I have a password box that is working but the user has to enter the password in twice in order for it to connect to the corresponding page. I'll post the javascript below. I would like for the user to only have to enter the password in once. I have no idea why this is happening. // JavaScript Document /* * Change the passwords and urls here * Make sure the passwords and urls are in the same order */ const passwords = ["7654", "6243", "video", "locked", "house", "road", "crescenthotel", "three", "sudoku", "seven", "book", "pig", "before", "photographs"]; const urls = [ "house-end", "locked-end", "video", "link-to-locked-game", "link-to-house-game", "composites-to-road-to-page-number", "crescent-hotel-page-number", "sudoku-answer-to-page-number", "sudoku-page", "video-page-number", "new-page", "list-of-page-numbers", "photographs-page-number", "photographs-puzzle" ]; // Get submit element const submit = document.getElementById("submit"); // When form is submitted, run passwordinput function submit.onclick = passwordinput; // Function that handles form action function passwordinput(e) { e.preventDefault(); // Value in password input let password = document.getElementById("pass").value; // Makes password lowercase in case of caps lock if (passwords.includes(password.toLowerCase())) { // Get the index of the password const index = passwords.indexOf(password.toLowerCase()); // Redirect to different page based on the index location.href = urls[index]; } else { // Display a message that the password was wrong let div = document.getElementById("text"); div.innerHTML = "<p>Try again!</p>"; } }
  • Create New...