Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't hide element properly...

Status
Not open for further replies.

fdgsogc

Vendor
Feb 26, 2004
160
CA
I am creating a menu and submenu (vertical tree) using scripts like this with classnames and ids:
Code:
/* Shows subcategories  */
	function ShowSubcatories1(maincat1) {
	document.getElementById('subcat1').style.display = "block";
	}

/* Hides subcategories */
	function HideSubcategories1(maincat1) {
	document.getElementById('subcat1').style.display = "none";
	}

These scripts are repeated for each menu item.

I then use mouseover and mouseout to launch the scripts. Everything works fine.

PROBLEM:
I can't hide the last submenu selected. Once the user moves away from the menu, the last submenu moused over stays open.

I tried to use the Hide subcategories script on the parent DIV tag (ie, when the user mousesout of the parent div tag) but for some reason the cursor can see the parent div tag when floating between the children (submenu) div tags and so it no longer allows for the submenu to become visible.

Any ideas how to reset all elements to same values as when page loads?
 
In your functions, there's a parameter passed called maincat1, but it's never refered to in the function. What is its purpose?

As well, you should use one show function and one hide function for everything, not one function for each ID.

Lee
 
I use one show and hide for each ID. I was just simplifying because I am using ColdFusion to dynamically generate the ID codes.

You may be right. It may be redundant. I am not a very experienced programmer. Here is my statement calling the function.
Code:
<dt class="catrow" id="cat1" onMouseOver="ShowSubcatories1('maincat1'),this.className='catrowhover'">
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top