Jump to content

Archived

This topic is now archived and is closed to further replies.

freakus_maximus

PHP/Javscript Echo

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]

Share this post


Link to post
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.

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites
You can jump in and out of PHP as much as you want.

Share this post


Link to post
Share on other sites

×

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.