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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.