TenVolt
                          Tech Notes
JavaScript > Forms / Layers / Pop-up menus articles:

 • Solving the "form elements show through pop-up menu layer" problem

Return to index of articles

Solving the "form elements show through pop-up menu layer" problem

Category: JavaScript
Category: Forms / Layers / Pop-up menus

Background

Pop-up menus are a nice feature of Macromedia Dreamweaver and other programs. Supported by most current browsers, they use layers to create little pop-up (or drop-down if you prefer) menus, allowing users to quickly navigate your site. Unfortunately, some form elements such as SELECT boxes (also known as list-boxes or drop-down menus) show THROUGH your pop-up menus, making the menus ugly and sometimes even unusable.

This is caused by the fact that some form elements are actually rendered by the operating system, not the browser, so no matter how you order things with Z-Index etc. the operating system renders the form elements last, putting them on top of everything else.

The solution / workaroundThere is no way to stop the operating system from rendering the form elements last, so what can we do? How about... not render them at all! Basically our workaround is to make the form elements disappear whenever a pop-up menu appears, so that the form elements will not be rendered over top. Now this sounds a little bit odd but in practice it's actually not as noticeable as it sounds, because your attention is focused on the menu item you are moving your mouse to, waiting for the menu to pop up, reading the items in the menu etc. You hardly even notice that the SELECT elements on the page disappear when the pop-up menu appears.

Possibly not the most elegant solution, but it works and it made my client happy on a particular job.

How to do it

1. download the modified mm_menu.js file by clicking here

2. unzip the .js file and put it in your site, overwriting the mm_menu.js file which Dreamweaver creates (keep a backup if you want).

3. make sure your forms are always called "FORM1" (e.g. your form tag looks something like this:

on any page that has pop-up menus

That's it that's all. The modified mm_menu.js script automatically looks in document.form1 for any SELECT elements and hides them when the pop-up menu appears, then shows them again when the menu disappears.

Limitations If you have more than one form on a page, then only the one named "FORM1" will be affected. If only one of the forms have a SELECT tag in them, then name that form FORM1. If both have a SELECT tag in them, then you're going to have to adjust your layout so that one of them doesn't "underlap" (the opposite of overlap :-) ) the pop-up menus.

This is hopefully not a problem, e.g. I do have 2 forms on some of my pages but one of them is a tiny Search form in the top right corner which never interferes with the pop-up menus, and it doesn't have a SELECT element in it anyway.

If you really need to have 2 forms with SELECT tags, both in locations with overlapping pop-up menus, contact us and we'll write a custom script which hides SELECT tags in both forms. For a small fee of course...

1/1/2005

 TuneVault
 Music & MP3's
 10v Calendar
 Online & Easy
 Craigger
 Various & Misc.
 RetroVault
 Toys Toys Toys!
   

All contents ©2003 Ten Volt Consulting. All rights reserved.
Unauthorized duplication or use is a violation of applicable laws.
Webmaster Contact