taelmx Posted August 2, 2007 Share Posted August 2, 2007 I'm a complete beginner at php, I need a little help on this, I know there's a lot of errors, but I can't find them...>< I'm using TransMenu along with Subdreamer. So far I have gotten the menues to drop down and everything, and now I'm modding it with a little php so it dynamically updates the drop down menu. There are supposed to be dynamic subcategories, but I wanted to try just getting the columns first: <?php echo ' <link rel="stylesheet" href="/skins/euro/transmenu.css" type="text/css" /> <script language="javascript" src="/skins/euro/transmenuC.js"></script> <script language="javascript"> function init() { //========================================================================================== // if supported, initialize TransMenus //========================================================================================== // Check isSupported() so that menus arent accidentally sent to non-supporting browsers. // This is better than server-side checking because it will also catch browsers which would // normally support the menus but have javascript disabled. // // If supported, call initialize() and then hook whatever image rollover code you need to do // to the .onactivate and .ondeactivate events for each menu. //========================================================================================== if (TransMenu.isSupported()) { TransMenu.initialize(); // hook all the highlight swapping of the main toolbar to menu activation/deactivation // instead of simple rollover to get the effect where the button stays hightlit until // the menu is closed. '; for($i = 0; $i < $categoryrows; $i++) { echo 'menu'.$i.'.onactivate = function() { document.getElementById("'.$categoryname[$i].'").className = "hover"; }; menu'.$i.'.ondeactivate = function() { document.getElementById("'.$categoryname[$i].'").className = ""; }; } }'; echo ' } </script> </head> <body onload="init()"> <table cellpadding="0" cellspacing="0" border="0"> <tr>'; for($i = 0; $i < $categoryrows; $i++) { echo ' <td width="10" height="28"><img src="skins/euro/images/cat_center.jpg" /></td> <td width="100" height="28" align="center" background="skins/euro/images/cat_center.jpg"> <a id="'.$categoryname[$i].'" href="" class="category">'.$categoryname[$i].'</a> </td><td width="10" height="28"><img src="skins/euro/images/cat_right.jpg" /></td>'; }; echo ' </tr> </table> <script language="javascript"> // set up drop downs anywhere in the body of the page. I think the bottom of the page is better.. // but you can experiment with effect on loadtime. if (TransMenu.isSupported()) { //================================================================================================== // create a set of dropdowns //================================================================================================== // the first param should always be down, as it is here // // The second and third param are the top and left offset positions of the menus from their actuators // respectively. To make a menu appear a little to the left and bottom of an actuator, you could use // something like -5, 5 // // The last parameter can be .topLeft, .bottomLeft, .topRight, or .bottomRight to inidicate the corner // of the actuator from which to measure the offset positions above. Here we are saying we want the // menu to appear directly below the bottom left corner of the actuator //================================================================================================== var ms = new TransMenuSet(TransMenu.direction.down, 0, 0, TransMenu.reference.bottomLeft); //================================================================================================== // create a dropdown menu //================================================================================================== // the first parameter should be the HTML element which will act actuator for the menu //================================================================================================== //================================================================================================== //================================================================================================== '; for($i = 0; $i < $categoryrows; $i++) { echo ' var menu'.$i.' = ms.addMenu(document.getElementById("'.$categoryname[$i].'")); menu1.addItem("Download Anime", "http://www.manga4otaku.com/forums/index.php?autocom=articles&code=showcat&id=1"); menu1.addItem("Download Anime OST", "http://www.manga4otaku.com/forums/index.php?autocom=articles&code=showcat&id=2"); menu1.addItem("Download Artbooks", "http://www.manga4otaku.com/forums/index.php?autocom=articles&code=showcat&id=3"); menu1.addItem("Download Movies", "http://www.manga4otaku.com/forums/index.php?autocom=articles&code=showcat&id=4"); menu1.addItem("Download Music", "http://www.manga4otaku.com/forums/index.php?autocom=articles&code=showcat&id=5"); menu1.addItem("Get Megaupload Premium Links", "http://www.manga4otaku.com/forums/index.php?act=ST&f=149&t=4783") '; }; /* var submenu3 = menu3.addMenu(menu3.items[2]); submenu3.addItem("My Character", "http://www.manga4otaku.com/forums/living_avatars/index.php"); submenu3.addItem("My Families", "http://www.manga4otaku.com/forums/index.php?autocom=families"); submenu3.addItem("My Blog", "http://www.manga4otaku.com/forums/index.php?autocom=blogs"); var submenu3 = menu3.addMenu(menu3.items[3]); submenu3.addItem("Flash Galleries", "http://www.manga4otaku.com/forums/index.php?act=m4ogalleries"); submenu3.addItem("Flash Media", "http://www.manga4otaku.com/forums/index.php?act=m4omedia"); submenu3.addItem("Flash Upload", "http://www.manga4otaku.com/forums/index.php?act=SR&f=225"); var submenu3 = menu3.addMenu(menu3.items[4]); submenu3.addItem("Manga Projects", "http://www.manga4otaku.com/forums/index.php?act=m4oprojects"); submenu3.addItem("Website Tutorials", "http://www.manga4otaku.com/forums/index.php?act=m4otutorials"); submenu3.addItem("Banned Members", "http://www.manga4otaku.com/forums/index.php?act=ban"); submenu3.addItem("Image Host", "http://www.manga4otaku.com/forums/index.php?act=imageupload"); var menu4 = ms.addMenu(document.getElementById("navRPG")); menu4.addItem("RPG Modules", ""); menu4.addItem("M4O Banking", ""); menu4.addItem("M4O Shopping", ""); menu4.addItem("Other Games", ""); menu4.addItem("Casino System", "http://www.manga4otaku.com/forums/index.php?autocom=casino"); menu4.addItem("Arcade System", "http://www.manga4otaku.com/forums/index.php?autocom=arcade"); menu4.addItem("Refer Friends", "http://www.manga4otaku.com/forums/index.php?autocom=arcade"); var submenu4 = menu4.addMenu(menu4.items[0]); submenu4.addItem("RPG Pokemons", "http://www.manga4otaku.com/forums/index.php?act=pokemons"); submenu4.addItem("RPG Battle", "http://www.manga4otaku.com/forums/index.php?act=atkshop"); submenu4.addItem("RPG Guilds", "http://www.manga4otaku.com/forums/index.php?act=guilds"); submenu4.addItem("RPG Army", "http://www.manga4otaku.com/forums/index.php?autocom=army&core=armysystem2"); submenu4.addItem("RPG Inferno", "http://www.manga4otaku.com/forums/inferno.php?do=worldmap") var submenu4 = menu4.addMenu(menu4.items[3]); submenu4.addItem("M4O Lottery","http://www.manga4otaku.com/forums/index.php?act=p_lottery"); submenu4.addItem("M4O Quizzes","http://www.manga4otaku.com/forums/index.php?act=p_quiz"); submenu4.addItem("M4O Raffle","http://www.manga4otaku.com/forums/index.php?act=raffle"); submenu4.addItem("M4O Trivia","http://www.manga4otaku.com/forums/index.php?autocom=challenge"); submenu4.addItem("M4O Sudoku","http://www.manga4otaku.com/forums/index.php?autocom=sudoku"); var submenu4 = menu4.addMenu(menu4.items[2]); submenu4.addItem("Manga Items","http://www.manga4otaku.com/forums/index.php?act=shop&cat=40"); submenu4.addItem("Pets Items","http://www.manga4otaku.com/forums/index.php?act=shop&cat=160"); var submenu4 = menu4.addMenu(menu4.items[1]); submenu4.addItem("M4O Bank","http://www.manga4otaku.com/forums/index.php?act=bank"); submenu4.addItem("Army Bank","http://www.manga4otaku.com/forums/index.php?autocom=army&core=bank"); submenu4.addItem("Poki Bank","http://www.manga4otaku.com/forums/index.php?act=pokemons&CODE=store"); submenu4.addItem("Quick Bank","http://www.manga4otaku.com/forums/index.php?autocom=banksm"); var submenu4 = menu4.addMenu(menu4.items[6]); submenu4.addItem("Send Referrals","http://www.manga4otaku.com/forums/index.php?autocom=referal&code=choices"); submenu4.addItem("Pending Referrals","http://www.manga4otaku.com/forums/index.php?autocom=referal&code=pending"); submenu4.addItem("Finished Referrals","http://www.manga4otaku.com/forums/index.php?autocom=referal&code=downline"); submenu4.addItem("Cash Awards","http://www.manga4otaku.com/forums/index.php?autocom=referal&code=structure"); submenu4.addItem("Top Referrals","http://www.manga4otaku.com/forums/index.php?autocom=referal&code=leaderboard"); */ echo ' //================================================================================================== //================================================================================================== // write drop downs into page //================================================================================================== // this method writes all the HTML for the menus into the page with document.write(). It must be // called within the body of the HTML page. //================================================================================================== TransMenu.renderAll(); } </script> '; ?> EDIT: Wow, I just found the first error...thanks to the cool syntax highlighting...hehehe Guess you can't use contractions in comments...hehehe Quote Link to comment https://forums.phpfreaks.com/topic/62983-simple-dynamic-drop-down-menu/ 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.