html and javascript password: how to change display of an element if the password is correct? -


i need make password protected image in html of javascript, means, if enter correct password, image appear.i'm beginner, can't find error in this. don't know if if code written, thankful if help.

html:

    <img src="..." id="smiley"/>      <form>          picture password protected<br>enter password:<br>          <input type="password" name="password" id="password">          <input type="button" onclick="funcpass( );" value="ok">      </form> 

javascript:

    var password = getelementbyid("password").value;     function funcpass(password.value) {         if (password.value == "smiley")         {             document.getelementbyid("smiley").style.display = "block";         }         else         {             password.value = " ";         }      } 

in css changed image display property none

your code password needs in function itself. you're getting value twice (the value of value). try this:

function funcpass() {     var password = document.getelementbyid("password").value;     if (password == "in darkened room")     {         document.getelementbyid("smiley").style.display = "block";     }     else     {         password = "";     }  } 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -