Jump to content

Archived

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

Aesop

Echoing a javascript

Recommended Posts

Hello,

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

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

Ok, here it is attempted to be echoed;

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

on the page it spits out

[i]')" onmouseout="popout()">' [/i] followed by the 2nd image

Any suggestions?  :-\

Share this post


Link to post
Share on other sites
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. 

Share this post


Link to post
Share on other sites
[quote author=jvrothjr link=topic=100597.msg397241#msg397241 date=1152909371]
its all in the " ' single and doule quote

[/quote]

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

Share this post


Link to post
Share on other sites
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).

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.