freakus_maximus Posted May 18, 2006 Share Posted May 18, 2006 I need to echo this script for a dynamic navigation side menu and this is part of the collapse/expand menu for it, but I cannot seem to get the single/double quote correct. Stand alone in html, the code works fine, so I know it's an issue with the echo.The initial error is a parse error finding unexpected ";", which I can see obviously as part of the java script. Have been trying to wrap it all together with no luck.Thanks![code]echo '<script type="text/javascript">document.writeln('<img id="menu0Image" src="./images/minus.jpg" alt="Collapse" onClick="toggle(\'menu0Image\',\'menu0List\')';'">')';'</script><br>';[/code] Quote Link to comment https://forums.phpfreaks.com/topic/9942-phpjavscript-echo/ Share on other sites More sharing options...
ober Posted May 18, 2006 Share Posted May 18, 2006 [code]echo '<script type="text/javascript">document.writeln(\'<img id="menu0Image" src="./images/minus.jpg" alt="Collapse" onClick="toggle(\'menu0Image\',\'menu0List\')\';\'">')\';\'</script><br>';[/code]Give that a shot. You have to escape ALL single quotes.And I'm not sure why you're using an echo for this... surely you could jump out of PHP and just write that instead of echoing it. Quote Link to comment https://forums.phpfreaks.com/topic/9942-phpjavscript-echo/#findComment-36954 Share on other sites More sharing options...
freakus_maximus Posted May 18, 2006 Author Share Posted May 18, 2006 [!--quoteo(post=375014:date=May 18 2006, 01:56 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ May 18 2006, 01:56 PM) [snapback]375014[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]echo '<script type="text/javascript">document.writeln(\'<img id="menu0Image" src="./images/minus.jpg" alt="Collapse" onClick="toggle(\'menu0Image\',\'menu0List\')\';\'">')\';\'</script><br>';[/code]Give that a shot. You have to escape ALL single quotes.And I'm not sure why you're using an echo for this... surely you could jump out of PHP and just write that instead of echoing it.[/quote]That gave me a "Parse error: parse error, unexpected ')', expecting ',' or ';' in C:\ITPUB KBASE\htdocs\includes\testnav.php on line 32". Line 32 is that line.OK, looks like jumping out of PHP worked fine. I will just jump back in/out so I can have it cycle through the "menu0Image\" and "menu0List\" options for each catagory.Thanks Ober! Quote Link to comment https://forums.phpfreaks.com/topic/9942-phpjavscript-echo/#findComment-36957 Share on other sites More sharing options...
ober Posted May 18, 2006 Share Posted May 18, 2006 You can jump in and out of PHP as much as you want. Quote Link to comment https://forums.phpfreaks.com/topic/9942-phpjavscript-echo/#findComment-36959 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.