Qazsad Posted June 7, 2006 Share Posted June 7, 2006 Hello Guys Do you have sample codes for creating javascript Tree. Coz i would like to create a menu on my page and hiding its submenu first. The Submenu's will only be shown if The Mainmenu will be clicked and other submenus from other will be hidden if they are not part of the current mainmenu.Say Selecting MainMenu2: MainMenu1 MainMenu2 MM2_SubMenu1 MM2_SubMenu2 MainMenu3Selecting MainMenu1: MainMenu1 MM1_SubMenu1 MM1_SubMenu2 MainMenu2 MainMenu3 Quote Link to comment https://forums.phpfreaks.com/topic/11398-newbies-creating-menu-with-javascript-tree-neeeedsss-help/ Share on other sites More sharing options...
nogray Posted June 7, 2006 Share Posted June 7, 2006 try this[code]<script language="javascript">function hide(){ var sub_menus_array = new Array("sub1","sub2","sub3"); // sub menu ids for(i=0; i<sub_menus_array.length; i++){ document.getElementById(sub_menus_array[i]).style.display = "none"; }}function show(sub_menu){ hide(); document.getElementById(sub_menus_array[i]).style.display = "block";}<script><a href="#" onClick="show('sub1');">MainMenu1</a><div id="sub1" style="display:none;">MM1_SubMenu1MM1_SubMenu2</div><a href="#" onClick="show('sub2');">MainMenu2</a><div id="sub2" style="display:none;">MM2_SubMenu1MM2_SubMenu2</div><a href="#" onClick="show('sub3');">MainMenu3</a><div id="sub3" style="display:none;">MM3_SubMenu1MM3_SubMenu2</div>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11398-newbies-creating-menu-with-javascript-tree-neeeedsss-help/#findComment-42907 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.