Jump to content

Recommended Posts

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]
Link to comment
https://forums.phpfreaks.com/topic/9942-phpjavscript-echo/
Share on other sites

[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.

Link to comment
https://forums.phpfreaks.com/topic/9942-phpjavscript-echo/#findComment-36954
Share on other sites

[!--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!
Link to comment
https://forums.phpfreaks.com/topic/9942-phpjavscript-echo/#findComment-36957
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.