Jump to content

showing and hiding a div block


svgmx5

Recommended Posts

I'm having some problems hiding a div block and displaying another one.

 

this is my first attempt and creating something with JavaScript with out using a tutorial or anything so i would really appreciate any help, so i can learn

 

what i want is to have a div block display initially so when a user goes to the page they see the registration form, but if they already have an account they can just click a link that says log in and the registration form hides and the login form shows.

 

However right now its only hiding both and not displaying anything when the link is clicked

 

Here's the javascript code i'm using

<script type="text/javascript">  
function toggleview() {  

if(document.getElementById("login")){
	login.style.display = 'inline';
	document.getElementById("register").style.display = 'none';
}else{
	login.style.display = 'none';
	document.getElementById("register").style.display = 'inline';
}

if(document.getElementById("register")){
	login.style.display = 'inline'; 
	document.getElementById("login").style.display = 'none';
}else{
	login.style.display = 'none';
	document.getElementById("login").style.display = 'inline';
}

}  
</script>  

 

And here's what the link looks like

<h4><a href="#" onclick="toggleview()">Allready Have an Account?</a></h4>

 

Link to comment
https://forums.phpfreaks.com/topic/197674-showing-and-hiding-a-div-block/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.