I have created simple login button,which can only admin log in (only 1 password works).After clicking on a button "LOG IN" it takes me to the new html file.There is a form in this new html file that is hidden but I want it to be visible when i enter it with login.So I was thinking about document.getElementById("hidden_form").style.display = "block"; but that form is not in that HTML file so that cant work.
This is the javascript of the button (so when i click on it it opens a new html document)
<input type="password" id="password" /><br />
<input class="orangebutton" type="submit" value="Nastavi"
onclick="if (document.getElementById('password').value == 'password')
location.href='index.html'; else alert('Wrong password!');
" />
And this is the form that is hidden in index.html:
<form class="echo" id="form" style="display:none">
So I want it to change from display:none to display:block when I get redirected to the new site.I havent really got any ideas so far, except this one:use javascript to check which was the previous page client went on, and if it was the page of the login then put display:block , but if it isnt then do display:none. Im sure there is some much easier way, but cant think of any at the moment.
If you want to change something on a new/other page, you should do that in the other page. With javscript you cannot change something that isn't loaded yet.
Easiest way to do this with javascript would be something like this:
<script type="text/javascript">
if (location.search == "?show") {
document.getElementById("hidden_form").style.display = "block";
}
</script>
Note that this script should be executed after the <form>
is added to the DOM. So preferably in some document.ready
function or in a script block that is placed below the <form>
.