Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
08-23-2009, 01:20 PM #1
- Join Date
- Dec 2005
- Thanked 0 Times in 0 Posts
How to make the parent menu get selected in multi level menu?
How to make the parent menu get selected in multi level menu.
For example we have following multilevel menu:
I generated the above menus from db table of following structure
id | parent_id|title
using recursive method.
I would like to know the logic of how to put some class(say class="active") in the parent level
menus if its child is selected
For example if Menu2.1 or Menu2.2.1 or any child menus is clicked then Menu2 should be selected.
if Menu3.1 is clicked then Menu3 should be selected.
(Note: the page is reloaded when clicked on the menu links)
Thanks in advance for any valueable suggestions/hints/logic.
08-23-2009, 01:41 PM #2
- Join Date
- May 2006
- Thanked 82 Times in 79 Posts
That should get the top menuPHP Code:
$menu['id'] = $_GET['selectedMenu'];
$query = mysql_query ( Get the parent id from the database for $menu['id'] );
$menu = mysql_fetc_array($query);
} while ( $menu['parentid'] != 0 );