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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display drop down menu using onmouseover and onmouseout events

Status
Not open for further replies.

jmsummerlin

Programmer
Jun 7, 2006
1
I am messing around with drop down menus for my test web page.

Here is my aspx page:

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="home.aspx.vb" Inherits="TestWebMenu.home"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Test Menu</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema content=" <link rel="stylesheet" type="text/css" href="styles.css" >
</head>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<table>
<tr>
<td class="head" onmouseover="showLinks(1)" onmouseover="this.style.cursor='hand'; this.style.cursor='pointer';" onmouseout="hideLinks(1)">What's New?</td>
<td class="head">|</td>
<td class="head" onmouseover="showLinks(2)" onmouseout="hideLinks(2)">Animal Facts</td>
</tr>
<tr>
<td>
<table style="DISPLAY: none" class=submenu1 id="menuItem1">
<tr>
<td>Test Item 1</td>
</tr>
<tr>
<td>Test Item 2</td>
</tr>
</table>
</td>
<td></td>
<td>
<table style="DISPLAY: none" class=submenu1 id="menuItem2">
<tr>
<td>Test Item 3</td>
</tr>
<tr>
<td>Test Item 4</td>
</tr>
</table>
</td>
</tr>
</table>

</form>
</body>
</html>

Here is my script:

<script language="javascript">
function showLinks(menuID) {
//alert(menuID);
var menu1 = document.getElementById('menuItem1');
var menu2 = document.getElementById('menuItem2');
if (menuID = 1) {
menu1.style.display = 'inline';
} else if (menuID = 2) {
menu2.style.display = 'inline';
}
}

function hideLinks(menuID) {
//alert(menuID);
var menu1 = document.getElementById('menuItem1');
var menu2 = document.getElementById('menuItem2');
if (menuID = 1) {
menu1.style.display = 'none';
} else if (menuID = 2) {
menu2.style.display = 'none';
}
}
</script>

I have got the first menu to display on mouseover, but the second will not show up.

Also, I would like to keep the cursor as an pointer.

Lastly, I would like to be able to keep the submenus displayed while the mouse is still over them.

Any help would be greatly appreciated.
 
You should investigate some of the many non table-based menu scripts that are cross-browser, such as the Suckerfish dropdowns, etc. Using tables for menus is so unnecessary, and simply bloats your code more than needed.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top