I'm trying to create a custom drop down and using the code below it works pretty well - only one problem is if i have more than one drop down, all the links will only activate the first drop down. Any ideas on how I would fix that? (and yes I know about Suckerfish I just need to get this to work)
function toggle() {
var ele = document.getElementById("dropdown-items");
var text = document.getElementById("dropdown-menu");
if(ele.style.display == "block") {
ele.style.display = "none";
}
else {
ele.style.display = "block";
}
}
Html looks like:
<div id="mainSearch">
<div id="search-cat">
<div class="search-title">Destination</div>
<div id="cat-dropdown">
<a id="dropdown-menu" href="javascript:toggle();">Choose a Category...</a>
<div id="dropdown-items">
<ul>
<li id="dropdown-list"><a href="">Category One</a></li>
<li id="dropdown-list"><a href="">Category Two</a></li>
<li id="dropdown-list"><a href="">Category Three</a></li>
</ul>
</div>
</div>
</div>
<div id="search-cat">
<div class="search-title">Location</div>
<div id="cat-dropdown">
<a id="dropdown-menu" href="javascript:toggle();">Choose a Location...</a>
<div id="dropdown-items">
<ul>
<li id="dropdown-list"><a href="">Category One</a></li>
<li id="dropdown-list"><a href="">Category Two</a></li>
<li id="dropdown-list"><a href="">Category Three</a></li>
</ul>
</div>
</div>
</div>
</div>