Solved

How do I insert a java drop down menu

Posted on 2010-09-10
11
611 Views
Last Modified: 2013-11-23
I am trying to insert a java drop down menu into a web page.  I can do so with a regular menu by using

<!--#include virtual="menu.asp" -->

The problem is when I do this with with my java menu, as soon as you leave the main menu to try to navigate the sub menu it goes away.  Is there a way I can insert the menu so I can edit the menu in one single location when making changes to the menu both cosmetic and operational.
0
Comment
Question by:Pangeia
  • 6
  • 5
11 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 33649541
Java or javaSCRIPT?

Normally with JS you just do
<script src="menu.js" type="text/javascript"></script>
0
 

Author Comment

by:Pangeia
ID: 33649919
Yes.  In the header.

Im talking about doing something like this.

defalut.asp

<html>

<head>
<script src="Menu/dbMenu.js" type="text/javascript"></script>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>

<body>
<div align="left">
      <table border="0" width="600">
            <tr>
                  <td bgcolor="#B0F0F0">&nbsp;</td>
                  <td bgcolor="#000000">&nbsp;</td>
                  <td bgcolor="#B30000">&nbsp;</td>
            </tr>
      </table>
</div>
<!--#include virtual="menu.asp" -->
<div align="left">
      <table border="0" width="600">
            <tr>
                  <td bgcolor="#FFB409">&nbsp;</td>
                  <td bgcolor="#3F3362">&nbsp;</td>
                  <td bgcolor="#3FA490">&nbsp;</td>
            </tr>
      </table>
</div>

</body>

</html>

menu.asp

<html>
<head>
      <title>Dropdown menu Menu Test</title>
      <script src="Menu/dbMenu.js" type="text/javascript"></script>
      <link href="Menu/global.css" type="text/css" rel="stylesheet" media="screen">
      <link href="Menu/dropDown.css" type="text/css" rel="stylesheet" media="screen">
</head>
<body>

<ul id="menu" class="dbMenu onMouse">
      <li style="left: 0px; top: 0px; width: 4em">Home</li>
                  <li style=width:15em><a class="download" title="Initiates file download" target="_blank" href="displaycontent.pdf">
                  Drop down menu item</a></li>
</ul>

</body>
</html>
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 33652209
That would not be a good idea.
the menu needs to not be an html document

So either

<ul id="menu" class="dbMenu onMouse">
      <li style="left: 0px; top: 0px; width: 4em">Home</li>
                   <li style=width:15em><a class="download"  title="Initiates file download" target="_blank"  href="displaycontent.pdf">
                  Drop down menu item</a></li>
</ul>

or the most

<script src="Menu/dbMenu.js" type="text/javascript"></script>
      <link href="Menu/global.css" type="text/css" rel="stylesheet" media="screen">
      <link href="Menu/dropDown.css" type="text/css" rel="stylesheet" media="screen">
<ul id="menu" class="dbMenu onMouse">
      <li style="left: 0px; top: 0px; width: 4em">Home</li>
                   <li style=width:15em><a class="download"  title="Initiates file download" target="_blank"  href="displaycontent.pdf">
                  Drop down menu item</a></li>
</ul>

but I would not include dbMenu in the parent then.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:Pangeia
ID: 33662122
I have been instructed I have to make the menu centralized.  SO there is one place where I make all changes and they reflect on all pages.

With css I can do this with things like colors and sizes, but I need it to be so that if I rename a button, or change a link, I only have to do it once.

This is what I'm looking for.  From the way your solution looks it still has me having to go to every page and changing the link on each individual page.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 33662404
No, you only ever edit menu.asp
0
 

Author Comment

by:Pangeia
ID: 33662804
OK.  I tried to do what I thought you said.  I feel I need to explain... I have limited experience in web design and do not know java, but have been tasked with getting this done.  STRESS

When I replaced the code on the menu page with...

<script src="Menu/dbMenu.js" type="text/javascript"></script>
     <link href="Menu/global.css" type="text/css" rel="stylesheet" media="screen">
     <link href="Menu/dropDown.css" type="text/css" rel="stylesheet" media="screen">
<ul id="menu" class="dbMenu onMouse">
     <li style="left: 0px; top: 0px; width: 4em">Home</li>
                  <li style=width:15em><a class="download"  title="Initiates file download" target="_blank"  href="displaycontent.pdf">
                 Drop down menu item</a></li>
</ul>

it no longer loads into the web page.  Was I wrong in my interpretation that I was to make it a blank page and paste this in there?  Was I supposed to have left some of the original code there?
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 33662953
I cannot say it is the nicest menu I have ever seen, but it sure looks standalone enough to me:

<script src="http://www.javascriptkit.com/script/script2/dbmenu/dbMenu.js" type="text/javascript">

	/***********************************************
	* DbMenu script- by David Boggus: http://www.boggusweb.com/
	* Please keep this notice intact
	* Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and more
	***********************************************/

	</script>
	<link href="http://www.javascriptkit.com/script/script2/dbmenu/global.css" type="text/css" rel="stylesheet" media="screen">
	<link href="http://www.javascriptkit.com/script/script2/dbmenu/dropDown.css" type="text/css" rel="stylesheet" media="screen">
	<ul id="menu" class="dbMenu onMouse">

        <li><a href="http://www.javascriptkit.com">Home</a></li>
		<li>News
            <ul>
				<li><a href="http://www.cnn.com">CNN</a></li>
        <li><a href="http://news.bbc.co.uk">BBC News</a></li>
        <li><a href="http://abcnews.com">ABC News</a></li>
            </ul>

		</li>

	    <li>Web Design
            <ul>
                <li><a href="http://javascriptkit.com">JavaScipt Kit</a></li>
                <li><a href="http://dynamicdrive.com">Dynamic Drive</a></li>
                <li><a href="http://www.cssdrive.com">CSS Drive</a></li>
                <li><a href="http://www.codingforums.com">Coding Forums</a></li>

            </ul>
	    </li>
	    <li><a href="http://javascriptkit.com/jsref/">JS Reference</a></li>
	    <li><a href="http://javascriptkit.com/domref/">DOM Reference</a></li>

	</ul>

Open in new window

0
 

Author Comment

by:Pangeia
ID: 33663806
Thanks so much.

IT works great.

My menu inserts and when I move my mouse down to the sub menu, the menu stays and I can click my links.
0
 

Author Closing Comment

by:Pangeia
ID: 33663820
It helped me complete my task.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 33663834
Make sure to change the paths to your own paths. Perhaps that was your problem...
0
 

Author Comment

by:Pangeia
ID: 33663986
Actually, I did try tinkering with my original website I was working with.

The problem was very simple.

As you had stated I should not have had reference to the java script in the parent page.  Once I removed it, it started working.

Just thought I would throw that out there.  Thanks again.  Learned a lot.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question