Jump to content


Photo

PHP/Javscript Echo


  • Please log in to reply
3 replies to this topic

#1 freakus_maximus

freakus_maximus
  • Members
  • PipPipPip
  • Advanced Member
  • 177 posts

Posted 18 May 2006 - 05:52 PM

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!

echo '<script type="text/javascript">document.writeln('<img id="menu0Image" src="./images/minus.jpg" alt="Collapse"  onClick="toggle(\'menu0Image\',\'menu0List\')';'">')';'</script><br>';


#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 18 May 2006 - 05:56 PM

echo '<script type="text/javascript">document.writeln(\'<img id="menu0Image" src="./images/minus.jpg" alt="Collapse"  onClick="toggle(\'menu0Image\',\'menu0List\')\';\'">')\';\'</script><br>';

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.


Info: PHP Manual


#3 freakus_maximus

freakus_maximus
  • Members
  • PipPipPip
  • Advanced Member
  • 177 posts

Posted 18 May 2006 - 06:00 PM

[!--quoteo(post=375014:date=May 18 2006, 01:56 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ May 18 2006, 01:56 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
echo '<script type="text/javascript">document.writeln(\'<img id="menu0Image" src="./images/minus.jpg" alt="Collapse"  onClick="toggle(\'menu0Image\',\'menu0List\')\';\'">')\';\'</script><br>';

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!

#4 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 18 May 2006 - 06:03 PM

You can jump in and out of PHP as much as you want.

Info: PHP Manual





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users