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 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 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> 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 Link to comment https://forums.phpfreaks.com/topic/109947-solved-javscript-in-php/#findComment-564241 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.