Hello.

There is a problem in the following code: the script does not work.

The goal is to click on "click here" to hide the login div and transfer the user to the login helper.

I would welcome any critics and the best examples!

function loginHelper(){ document.getElementById("pass_forgot").onclick = function (){ document.getElementById("login").style.display = "none"; document.getElementById("login_help").style.display = "block"; } } 
 <div id = "login" class = "login_form"> <form id = "logger"> <label for id = "user_name">User name:</label> <input id = "user_name" name = "user_name" type = "text" placeholder = "user name"> <br> <label for id = "password">Password:</label> <input id = "password" name = "password" type = "text" placeholder = "password"> <br> <label for id = "email">Email:</label> <input id = "email" name = "email" type = "email" placeholder = "email"> <br> <label for = "remember_me">Remember you on this computer ? </label> <input type = "checkbox" name = "remember_me" id = "remember_me"> <br> <input type = "submit" value = "Login"> </form> <p id = "pass_forgot">Forgot your password? <a href="#login_help"> <button onclick = "loginHelper()">Click here!</button></a></p> <div id = "login_help" class = "login_help"> <form id = "helper"> <label for id = "email">Your current email:</label> <input id = "email" name = "email" type = "email" placeholder = "email"> <br> <input type = "submit" value = "Send"> </form> </div> 

  • what is "to throw the user on login helper"? - Igor
  • I did not understand the question .. what to specify? - Maks.Burkov 5:09
  • Why do you have a button inside the link? - Igor
  • I do not understand how this is connected with my question .. I decided to put it for beauty .. I am sure that this is not the problem .. I tried it without .. - Maks.Burkov
  • So formulate the problem, or should it be guessed? - Igor

1 answer 1

 function loginHelper(){ // document.getElementById("pass_forgot").onclick = function (){ document.getElementById("login").style.display = "none"; document.getElementById("login_help").style.display = "block"; // } } 
 <div id = "login" class = "login_form"> <form id = "logger"> <label for id = "user_name">User name:</label> <input id = "user_name" name = "user_name" type = "text" placeholder = "user name"> <br> <label for id = "password">Password:</label> <input id = "password" name = "password" type = "text" placeholder = "password"> <br> <label for id = "email">Email:</label> <input id = "email" name = "email" type = "email" placeholder = "email"> <br> <label for = "remember_me">Remember you on this computer ? </label> <input type = "checkbox" name = "remember_me" id = "remember_me"> <br> <input type = "submit" value = "Login"> </form> <p id = "pass_forgot">Forgot your password? <a href="#login_help"> <button onclick = "loginHelper()">Click here!</button></a></p> </div> <div id = "login_help" class = "login_help" style="display:none;"> <form id = "helper"> <label for id = "email">Your current email:</label> <input id = "email" name = "email" type = "email" placeholder = "email"> <br> <input type = "submit" value = "Send"> </form> </div> 

  • one
    Yes, most likely: 1. The TS forgot to close one div 2. Hid not login, a logger (ie the form itself) - garmayev