Jump to content


Photo

Echoing a javascript


  • Please log in to reply
4 replies to this topic

#1 Aesop

Aesop
  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationPortland Oregon

Posted 14 July 2006 - 08:24 PM

Hello,

Having a tricky problem with this snippet.  Here is the original source, not echoed yet;

<a href="#" onmouseover="popup('<img src=$folder\$fullsized>')" onmouseout="popout()"><img src=$folder\$thumbnail></a><br />

Ok, here it is attempted to be echoed;

echo "<a href=\"stuff.php\" onmouseover=\"popup('<img src=\"$folder\$fullsized\">')\" onmouseout=\"popout()\">'<img src=\"$folder\$thumbnail\">'</a><br />";

on the page it spits out

')" onmouseout="popout()">' followed by the 2nd image

Any suggestions?  :-\

#2 jvrothjr

jvrothjr
  • Members
  • PipPipPip
  • Advanced Member
  • 300 posts
  • LocationOhio

Posted 14 July 2006 - 08:36 PM

its all in the " ' single and doule quote

If you understand everything you know nothing!

http://rcchjr.awardspace.com/

#3 Aesop

Aesop
  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationPortland Oregon

Posted 14 July 2006 - 08:36 PM

Yea, the actual java is being involved.

However, this echo is in conjunction with repeating rows.  so this echo gets repeated x number of times i specify in my database query. 

#4 Aesop

Aesop
  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationPortland Oregon

Posted 14 July 2006 - 08:39 PM

its all in the " ' single and doule quote


Yes it is.  And the escaping slashes.  But it's really eluding me...

#5 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 14 July 2006 - 09:28 PM

in general, when you're going to be echoing a lot more HTML than variables, i would suggest using single quotes to delimit the string:

echo '<a href="#" onmouseover="popup(\'<img src='.$folder.'\\'.$fullsized.'>\')" onmouseout="popout()"><img src='.$folder.'\\'.$thumbnail.'></a><br />';

in this case, i think escaping the single quotes is the lesser of the evils.

the other thing to point out is the backslash.  backslash is a general escape character; to get a LITERAL backslash printed, you need to escape the backslash with a backslash (whee).  otherwise, the backslash would be interpreted as escaping the '$' of $fullsized and $thumbnail, which would turn THEM into literals (ie. '$fullsized' rather than its value).




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users