Adding pop up menu on Headlines
Here you will learn sticking a pop up menu on a title. We have added it on the product list. When the cursor of mouse goes on to pop up menu, it opens the list of the menu automatically. For generating the pop-up menu, you will have to code a scripting language, JavaScript that will generate a .jsp file. In the JavaScript, we have used function mmLoadMenus() to generate mm_menu.jsp file that generates the popup menu.
<?php
//$REDIRECT_URL;
$redirectUrl = $_SERVER['REQUEST_URI'] ;
$indexHighlight="";
$aboutusHighlight="";
$productslistHighlight="";
$productrangesHighlight="";
$contactusHighlight="";
if(ereg("/index.php", $redirectUrl)){
$indexHighlight=
"style=\"color:#3faffe; text-decoration:underline;\"";
}
if(ereg("/about-us.php", $redirectUrl)){
$aboutusHighlight=
"style=\"color:#3faffe; text-decoration:underline;\"";
}
if(ereg("/products-list.php", $redirectUrl)){
$productslistHighlight=
"style=\"color:#3faffe; text-decoration:underline;\"";
}
if(ereg("/product-ranges.php", $redirectUrl)){
$productrangesHighlight=
"style=\"color:#3faffe; text-decoration:underline;\"";
}
if(ereg("/contact-us.php", $redirectUrl)){
$contactusHighlight=
"style=\"color:#3faffe; text-decoration:underline;\"";
}
?>
<script language="JavaScript">
function mmLoadMenus() {
if (window.mm_menu_0715193556_0) return;
window.mm_menu_0715193556_0 = new Menu("root",162,18,"",
12,"#FFFFFF","#FFFFFF","#666666","#66CCFF","left",
"middle",3,0,1000,-5,7,true,true,true,0,true,true);
<?
include "./comman.php";
session_start();
$link= mysql_connect($host,$dbuser,$dbpassword) or
die("Mysql Connection Error:" .mysql_error());
mysql_select_db($database,$link) or
exit ("Database Selection Error:" .mysql_error());
$query = "SELECT * FROM majorproduct";
$result = mysql_query($query,$link) or
exit("Product Sql error:" .mysql_error());
while($row=mysql_fetch_array($result)){
?>
mm_menu_0715193556_0.addMenuItem("<?=$row['major_product']?>",
"location='products.php?productId=<?=$row['Id']?>'");
<?
}
?>
mm_menu_0715193556_0.hideOnMouseOut=true;
mm_menu_0715193556_0.bgColor='#555555';
mm_menu_0715193556_0.menuBorder=1;
mm_menu_0715193556_0.menuLiteBgColor='#FFFFFF';
mm_menu_0715193556_0.menuBorderBgColor='#333333';
mm_menu_0715193556_0.writeMenus();
}
</script>
<script language="JavaScript" src="mm_menu.js"></script>
<script language="JavaScript1.2">mmLoadMenus();</script>
<div align="left" id="head">
<div class="menu">
<ul>
<li><a href="index.php" title="Home"
<?=$indexHighlight?>>Home</a></li>
<li><a href="about-us.php" title="About Us"
<?=$aboutusHighlight?>>About Us</a></li>
<li><a href="products-list.php" name="link1"
title="Products List" id="link1" onmouseover=
"MM_showMenu(window.mm_menu_0715193556_0,0,19,null,'link1')"
onmouseout="MM_startTimeout();"
<?=$productslistHighlight?>>Products List</a></li>
<li><a href="product-ranges.php" title="Product Ranges"
<?=$productrangesHighlight?>>Product Ranges</a></li>
<li><a href="contact-us.php" title="Contact Us"
<?=$contactusHighlight?>>Contact Us</a></li>
</ul>
</div>
</div>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.