Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 789653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:33:31+00:00 2026-05-14T21:33:31+00:00

My first post here. I want to make a horizontal menu with submenu’s sliding

  • 0

My first post here. I want to make a horizontal menu with submenu’s sliding down on mouseover. I know I could use jQuery but this is to practice my javascript skills.

I use the following code:

var up = new Array()
var down = new Array()
var submenustart

function titleover(headmenu, inter)
{
 submenu = headmenu.lastChild

 up[inter] = window.clearInterval(up[inter])
 down[inter] = window.setInterval("slidedown(submenu)",1)
}

function slidedown(submenu)
{
 if(submenu.offsetTop < submenustart)
 {
  submenu.style.top = submenu.offsetTop + 1 + "px"
 }
}

function titleout(headmenu, inter)
{
 submenu = headmenu.lastChild

 down[inter] = window.clearInterval(down[inter])
 up[inter] = window.setInterval("slideup(submenu)", 1)

}

function slideup(submenu)
{
 if(submenu.offsetTop > submenustart - submenu.clientHeight + 1)
 {
  submenu.style.top = submenu.offsetTop - 1 + "px"
 }
}

The variable submenustart gets appointed a value in another function which is not relevant for my question.
HTML looks like this:

<table class="hoofding" id="hoofding">
 <tr>
  <td onmouseover="titleover(this, 0)" onmouseout="titleout(this, 0)"><a href="#" class="hoofdinglink" id="hoofd1">AAAA</a>

  <table class="menu">
   <tr><td><a href="...">1111</a></td></tr>
   <tr><td><a href="...">2222</a></td></tr>
   <tr><td><a href="...">3333</a></td></tr>
  </table></td>

  <td onmouseover="titleover(this, 1)" onmouseout="titleout(this, 1)"><a href="#" class="hoofdinglink">BBBB</a>

  <table class="menu">
   <tr><td><a href="...">1111</a></td></tr>
   <tr><td><a href="...">2222</a></td></tr>
   <tr><td><a href="...">3333</a></td></tr>
   <tr><td><a href="...">4444</a></td></tr>
   <tr><td><a href="...">5555</a></td></tr>
  </table></td>
        ...
 </tr>
</table>

What happens is the following:
If I go over and out (for ex) menu A it works fine.
If i go now over menu B the interval applied to A is now applied to B. There are now 2 interval functions applied to B. The one originally for A and a new one triggered by the mouseover on B.
If I would go to A all the intervals are now applied to A.

I have been searching for hours but and I am completely stuck.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T21:33:32+00:00Added an answer on May 14, 2026 at 9:33 pm

    My first suggestion is to

    1. Practice using semicolons properly and not relying on semicolon insertion
    2. Don’t pass functions as strings (which requires an implicit eval)
    3. use JavaScript to attach events in a non-obtrusive manner

    .

    var up   = [],
        down = [],
        submenustart;
    
    function titleover(headmenu, inter) {
        up[inter]   = window.clearInterval(up[inter]);
        down[inter] = window.setInterval(function() { slidedown(headmenu.lastChild); }, 1);
    }
    
    function slidedown(submenu) {
        if ( submenu.offsetTop < submenustart  ) {
            submenu.style.top = submenu.offsetTop + 1 + "px";
        }
    }
    
    function titleout(headmenu, inter) {
        down[inter] = window.clearInterval(down[inter]);
        up[inter]   = window.setInterval(function() { slideup(headmenu.lastChild); }, 1);
    }
    
    function slideup(submenu) {
        if ( submenu.offsetTop > submenustart - submenu.clientHeight + 1 ) {
            submenu.style.top = submenu.offsetTop - 1 + "px";
        }
    }
    

    My second suggestion is to not use tables for menus, as they aren’t tabular data. Instead, use an unsorted list.

    <ul class="hoofding" id="hoofding">
        <li onmouseover="titleover(this, 0)" onmouseout="titleout(this, 0)">
            <a href="#" class="hoofdinglink" id="hoofd1">AAAA</a>
            <ul class="menu">
                <li><a href="...">1111</a></li>
                <li><a href="...">2222</a></li>
                <li><a href="...">3333</a></li>
            </ul>
        </li>
        <li onmouseover="titleover(this, 1)" onmouseout="titleout(this, 1)">
            <a href="#" class="hoofdinglink">BBBB</a>
            <ul class="menu">
                <li><a href="...">1111</a></li>
                <li><a href="...">2222</a></li>
                <li><a href="...">3333</a></li>
            </ul>
        </li>
    </ul>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all, first post and a noob in Android programming, but willing to learn!
this is my first post, and it covers something which I've been trying to
I want to make a PHP JSON data foreach, but I met some problem.
Here goes my first question. First of all I'm new with Java and still
My controller has abstract base controller. I want to access the form post data
When my users log into the website their first name, last name and ID
I have a script that sends out a push notification to users based on
I'm having problems using the DWM functionality of Windows Vista/7 on Java windows. I
I have a component I created that works like a Viewstack but the next
I have tried to get this to work a million times. I have lef

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.