I've only just started to use JavaScript, but I was attempting to create a simple function that would allow a user to click on a link were it would show or hide a DIV. I managed to get the DIV to show when the link it clicked, but it when it's clicked again it doesn't want to hide.
Here's the code on the HTML link.
Anyone got any pointers were I could be going wrong?
Code:
var choice = 'hidden';
function showLogin(choice) {
if (choice == 'hidden'){
document.getElementById('login').style.display='block';
var choice = 'display';}
else if (choice == 'display'){
document.getElementById('login').style.display='none';
var choice = 'hidden';}}
Here's the code on the HTML link.
Code:
<a href="javascript:showLogin(choice);">
Anyone got any pointers were I could be going wrong?
Last edited: