[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.2

Small Fix Needed For Simple Pulldown Menu System

Asked by shattered_rib in JavaScript

Tags: onmouseout

Hi Everyone,

I'm looking for a "reset" adjustment for this menu system.  Here's what happens: If you hover over a menu selection and then move your mouse cursor off of the menu, when you return your mouse to that menu, the last item you hovered over will still be highlighted.  I'm hoping someone can help by writing up a something that simply resets the menu to it's original state onmouseout (I simply don't know enough about JavaScript to do it).  This might be something a little easier to understand if you see the code...so here it is in 3 files, a js, a css and a html.

-----------------------------------------------------------------
-----------------------------------------------------------------
CascadeMenu.js
-----------------------------------------------------------------
-----------------------------------------------------------------

function InitMenu()
{
  var bar = menuBar.children    

  for(var i=0;i < bar.length;i++)
        {
             var menu=eval(bar[i].menu)
             menu.style.visibility = "hidden"
             bar[i].onmouseover = new Function("ShowMenu("+bar[i].id+")")
             var Items = menu.children
             for(var j=0; j<Items.length; j++)
                  {
                    var menuItem = eval(Items[j].id)
                         
                         if(menuItem.menu != null)
                               {
                                menuItem.innerHTML += "<Span Id="+menuItem.id+"_Arrow class='Arrow'>4</Span>"
                                //var tmp = eval(menuItem.id+"_Arrow")
                                // tmp.style.pixelLeft = menu.getBoundingClientRect().Right //- tmp.offsetWidth - 15
                                FindSubMenu(menuItem.menu)}
                        
                          if(menuItem.cmd != null)
                               {
                               menuItem.onclick = new Function("Do("+menuItem.id+")") }
                              
                    menuItem.onmouseover = new Function("highlight("+Items[j].id+")")
                  
                  }    
        
        }  
}
function FindSubMenu(subMenu)
{
            var menu=eval(subMenu)
            var Items = menu.children
             for(var j=0; j<Items.length; j++)
                  {
                    menu.style.visibility = "hidden"
                    var menuItem = eval(Items[j].id)
                    
                    
                    if(menuItem.menu!= null)
                          {
                                menuItem.innerHTML += "<Span Id="+menuItem.id+"_Arrow class='Arrow'>4</Span>"
                                // var tmp = eval(menuItem.id+"_Arrow")
                                //tmp.style.pixelLeft = 35 //menuItem.getBoundingClientRect().right - tmp.offsetWidth - 15
                                FindSubMenu(menuItem.menu)
                          }

                          if(menuItem.cmd != null)
                               {
                               menuItem.onclick = new Function("Do("+menuItem.id+")") }
                              
                    menuItem.onmouseover = new Function("highlight("+Items[j].id+")")
                         
                  }  
}
function ShowMenu(obj)
{
  HideMenu(menuBar)
  var menu = eval(obj.menu)
  var bar = eval(obj.id)
  bar.className="barOver"
  menu.style.visibility = "visible"
  menu.style.pixelTop =  obj.getBoundingClientRect().top + obj.offsetHeight + Bdy.scrollTop-2
  menu.style.pixelLeft = obj.getBoundingClientRect().left + Bdy.scrollLeft-2
}

function highlight(obj)
{
  var PElement = eval(obj.parentElement.id)
  if(PElement.hasChildNodes() == true)
  {  var Elements = PElement.children
       for(var i=0;i<Elements.length;i++)
       {
             TE = eval(Elements[i].id)
             TE.className = "menuItem"
       }
      }
  obj.className="ItemMouseOver"
  window.defaultStatus = obj.title
  ShowSubMenu(obj)
}

function Do(obj)
{
 var cmd = eval(obj).cmd      
 window.navigate(cmd)
 
}

function HideMenu(obj)
{
             if(obj.hasChildNodes()==true)
                    {  
                          var child = obj.children    
                         
                          for(var j =0;j<child.length;j++)
                              {
                                    if (child[j].className=="barOver")
                                    {var bar = eval(child[j].id)
                                     bar.className="Bar"}
                                     
                                    if(child[j].menu != null)
                                      {
                                            var childMenu = eval(child[j].menu)
                                            if(childMenu.hasChildNodes()==true)
                                                       HideMenu(childMenu)
                                            
                                                childMenu.style.visibility = "hidden"
                                           }
                              }
                    
                    }
}
function ShowSubMenu(obj)
{
  PMenu = eval(obj.parentElement.id)
      HideMenu(PMenu)
  if(obj.menu != null)
  {
  var menu = eval(obj.menu)
  menu.style.visibility = "visible"
  menu.style.pixelTop =  obj.getBoundingClientRect().top + Bdy.scrollTop+6
  menu.style.pixelLeft = obj.getBoundingClientRect().right + Bdy.scrollLeft-6
  if(menu.getBoundingClientRect().right > window.screen.availWidth )
       menu.style.pixelLeft = obj.getBoundingClientRect().left - menu.offsetWidth
 }
}

-----------------------------------------------------------------
-----------------------------------------------------------------
CascadeMenu.css
-----------------------------------------------------------------
-----------------------------------------------------------------
.menuBar {
      position: relative;
      background-color: transparent;
      text-align: left;
}
.Bar {
      border: 1px solid #FFFFFF;
      border-bottom: 0px;
      float: left;
      width: 100px;
      cursor: hand;
      text-indent: 2px;
      position: relative;
      background: #FFFFFF;
      padding: 4px;
      font-weight: bold;
}
.menu {
      border: 1px solid #666666;
      visibility: hidden;
      width: 150px;
      position: absolute;
      background-color: #F7F7F7;
      text-indent: 6px;
}
.menuItem {
      padding-right: 16px;
      padding-left: 0px;
      width: 100%;
      cursor: hand;
      line-height: 20px;
      text-indent: 6px;
}
.ItemMouseOver {
      padding-right: 16px;
      width: 100%;
      cursor: hand;
      color: #000000;
      line-height: 20px;
      background-color: #CED7E1;
}
.ItemMouseOut {
      width: 100%;
      background-color: #F7F7F7;
}
.Arrow {
      float: right;
      font: 12px Webdings;
      position: absolute;
}
.barOver {
      border: 1px solid #666666;
      border-bottom: 0px;
      float: left;
      width: 100px;
      cursor: hand;
      text-indent: 2px;
      position: relative;
      background-color: #F7F7F7;
      padding: 4px;
      font-weight: bold;
}

-----------------------------------------------------------------
-----------------------------------------------------------------
test.htm
-----------------------------------------------------------------
-----------------------------------------------------------------
<html>
<head>
<title>Test</title>
<link href="CascadeMenu.css" rel="stylesheet" type="text/css">
<script language="javascript" src="CascadeMenu.js"></script>
</head>

<body OnLoad="InitMenu()" Onclick="HideMenu(menuBar)" id="Bdy">
<!--Begin Menu -->
<div Id="menuBar" class="menuBar" >
<div Id="Bar1" class="Bar" menu="menu1">Menu #1</div>
<div Id="Bar2" class="Bar" menu="menu2">Menu #2</div>
</div>
<!--MenuItem Definition -->
<div Id="menu1" class="menu" >
<div Id="menuItem1_1" class="menuItem" menu="menu3">SubMenu #1</div>
<div Id="menuItem1_2" class="menuItem" title="Yahoo!" cmd="http://yahoo.com">Yahoo!</div>
<div Id="menuItem1_3" class="menuItem" title="Google" cmd="http://google.com">Google</div>
</div>
<div Id="menu2" class="menu">
<div Id="menuItem2_1" class="menuItem">Page #1</div>
<div Id="menuItem2_2" class="menuItem">Page #2</div>
<div Id="menuItem2_3" class="menuItem">Page #3</div>
</div>
<div id="menu3" class="menu">
<div Id="menuItem6_1" class="menuItem">Page #1-1</div>
<div Id="menuItem6_2" class="menuItem">Page #1-2</div>
<div Id="menuItem6_3" class="menuItem" menu="menu4">SubMenu #1-1</div>
</div>
<div id="menu4" class="menu">
<div Id="menuItem7_1" class="menuItem">Page #1-1-1</div>
<div Id="menuItem7_2" class="menuItem">Page #1-1-2</div>
<div Id="menuItem7_3" class="menuItem">Page #1-1-3</div>
</div>
<!--End Menu -->
</body>
</html>
-----------------------------------------------------------------
-----------------------------------------------------------------
To recreate the issue, hover over Menu#1 and then a sub-selection (you should see the item highlight with a light blue color) from there move your mouse cursor over to another Menu item (#2 for example).  If you move your cursor back over to Menu #1 you'll see that your previous selection will still be highlighted.

I don't think this is technically a difficult thing to fix, but then again I don't know much about JavaScript so...500 points to the one that can help me out.

Thanks for your time,
s_r
[+][-]03/03/04 12:51 AM, ID: 10502795Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: JavaScript
Tags: onmouseout
Sign Up Now!
Solution Provided By: MaB
Participating Experts: 4
Solution Grade: A
 
[+][-]03/02/04 06:49 AM, ID: 10495403Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/02/04 06:50 AM, ID: 10495409Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/02/04 06:50 AM, ID: 10495411Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/02/04 06:51 AM, ID: 10495420Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/02/04 06:56 AM, ID: 10495467Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/02/04 07:03 AM, ID: 10495543Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/02/04 07:27 AM, ID: 10495816Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/02/04 07:37 AM, ID: 10495910Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/02/04 12:21 PM, ID: 10498702Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/02/04 01:00 PM, ID: 10499130Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/02/04 11:52 PM, ID: 10502561Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/03/04 12:15 AM, ID: 10502670Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/03/04 06:37 AM, ID: 10504898Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/03/04 02:54 PM, ID: 10509440Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92