i am having some trouble with DHTML
i am trying to display a div after someone enters the correct password.
what am i doing wrong:
also, i can't even seem to change textcolor:
thanks!
and also, sorry for pasting huge chunks of code but i cant seem to use the pastewebsite.
i am trying to display a div after someone enters the correct password.
what am i doing wrong:
| Code: |
| <html>
<head> <script type="text/javascript"> function start() { mydiv = document.getElementById("mydiv"); mydiv.style.display = "none"; //to hide it //mydiv.style.visibility = "block"; to show it } function go() { var pass=document.getElementById('bi').value; if (pass=="password") { alert("correct password"); alert("the password you typed was:" + pass); mydiv2 = document.getElementById("mydiv"); mydiv2.style.visibility = "block"; } else { alert("you typed the wrong password"); alert("the password you typed was:" + pass); } } </script> </head> <body onload="start()"> <input type="password" id="bi" /> <input type="button" onclick="go()" value="Submit" /> <div id="mydiv"> <p> you got in to the system!</p> </div> </body> </html> |
also, i can't even seem to change textcolor:
| Quote: |
| <html>
<head> <title>getElementById example</title> <script type="text/javascript"> function changeColor(newColor){ elem = document.getElementById("para1"); elem.style.color = newColor; } </script> </head> <body> <p id="mytext">Some text here</p> <button onclick="changeColor('blue');">blue</button> <button onclick="changeColor('red');">red</button> </body> </html> |
thanks!
and also, sorry for pasting huge chunks of code but i cant seem to use the pastewebsite.
