dhimo Posted April 8, 2007 Share Posted April 8, 2007 Hello, Can someone help me with this recursive function. As the function is right now it shows all parents and children. What I want to do is to expend parent to show children and when i click on a child then the menu does not collapse but remains. any ideas? thanks in advance function menu($parent = 0, $level = 0){ // where parent of 0 means it's top-level $retval = ""; $sql = mysql_query("SELECT * FROM " . TABLE_CATEGORIES . " WHERE parent='$parent' ORDER BY sort ASC"); $retval .= "<div id=\"verticalMenu\">\n"; $retval .= "<ul>\n"; while ($row = dbFetchAssoc($sql)) { extract($row); $retval .= "<li><a href=\"".friendlyURL($category_id)."\">" .$category."</a></li>\n"; $retval .= menu($category_id, intval($level) + 1); } $retval .= "</ul>\n"; $retval .= "</div>\n"; return $retval;} Link to comment Share on other sites More sharing options...
justsomeguy Posted April 9, 2007 Share Posted April 9, 2007 You'll want to wrap the children in a div or something similar and use CSS to toggle the display between "block" and "none". If you want them to click on a child, which would load another page, and have the menu opened to the page they are on, then you will want to write out some extra javascript to enable visibility on the elements that lead to where they are. Link to comment Share on other sites More sharing options...
Mr_CHISOL Posted April 9, 2007 Share Posted April 9, 2007 You don't need to use div's and sertainly not "display: none" to make such menus (I think the 2nd article mentions why that's bad..), take a look at these links:Horizontal doropdownsSuckerfish <-- personal favoriteGood Luck and Don't Panic! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now