jamesbond110 Posted June 12, 2008 Share Posted June 12, 2008 Hi. I have a Javascript menu, and I want to put it in a PHP document. You click the link and more links show up below it. The external javascript is put in the <head> and then the HTML for the menu is in an external php file and put in with an include. EXAMPLE: <head> <script src="scripts/nav.js" type="text/javascript"></script> </head> <div id="masterdiv"> <?php include 'scripts/nav.php'; ?> </div> nav.php looks like <?php echo '<div class="menutitle" onclick="SwitchMenu("sub1")">Home</div> <span class="submenu" id="sub1"> <a href="new.html">Newly Added</a><br> <a href="best.html">Top Rated</a><br> <a href="editorpick.html">Editor Picks</a><br> <a href="featured.html">Featured</a><br> </span> ?> But the script does not work. Live Demo: http://www.tobylands.com Quote Link to comment https://forums.phpfreaks.com/topic/109947-solved-javscript-in-php/ Share on other sites More sharing options...
kenrbnsn Posted June 12, 2008 Share Posted June 12, 2008 You are not quoting anything correctly. Try: <?php echo '<div class="menutitle" onclick="SwitchMenu(\'sub1\')">Home</div> <span class="submenu" id="sub1"> <a href="new.html">Newly Added</a><br> <a href="best.html">Top Rated</a><br> <a href="editorpick.html">Editor Picks</a><br> <a href="featured.html">Featured</a><br> </span>'; ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/109947-solved-javscript-in-php/#findComment-564224 Share on other sites More sharing options...
rhodesa Posted June 12, 2008 Share Posted June 12, 2008 or just remove the PHP from the equation: <div class="menutitle" onclick="SwitchMenu('sub1')">Home</div> <span class="submenu" id="sub1"> <a href="new.html">Newly Added</a><br> <a href="best.html">Top Rated</a><br> <a href="editorpick.html">Editor Picks</a><br> <a href="featured.html">Featured</a><br> </span> Quote Link to comment https://forums.phpfreaks.com/topic/109947-solved-javscript-in-php/#findComment-564228 Share on other sites More sharing options...
jamesbond110 Posted June 12, 2008 Author Share Posted June 12, 2008 To kenrbnsn: I have the code correctly quoted, but for some reason I copied it wrong onto my post. eh. To rhodesa: Worked!... Well thanks for the help then. Thanks for being patient with an idiot Quote Link to comment https://forums.phpfreaks.com/topic/109947-solved-javscript-in-php/#findComment-564241 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.