...

View Full Version : close drop down menu



Bob42
08-24-2008, 06:56 PM
I've got an auto-suggestion menu. A drop down menu appears when the user begins to type into a search form. I want the menu to disappear when the user clicks anywhere outside of the menu.



function disappear()
{
var menu = document.getElementById("suggestions");
menu.style.display = 'none';
}


I've got something like that set up so far. I just don't know how to use it for when the user clicks on the page.

Philip M
08-24-2008, 07:21 PM
You need to include the whole of the page outside the menu into a <div>, then something like:-


<script type = "text/javascript">
function disappear(){
var menu = document.getElementById("suggestions");
menu.style.display = 'none';
}
</script>

<div id = "div1" onclick = "disappear()">
text here <br>
more text here<br>
still more stuff here<br>
</div>


It is your responsibility to die() if necessary….. - PHP Manual



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum