From: Andrew Koptyaev on 18 Feb 2010 09:04 "Stefan Weiss" <krewecherl(a)gmail.com> сообщил(а) в новостях следующее:jM-dnV_r3rue1eDWnZ2dnUVZ7sCdnZ2d(a)giganews.com... > On 18/02/10 14:34, Andrew Koptyaev wrote: >> I have html in the PHP variable like: >> $face_form = '<h3>Leave a Reply</h3><div class="cancel-comment-reply">'; >> >> I want pass this variable by onclick to javascript. Like: >> echo '<a href="#modalcomment" onlick="modalcommenttask(' . $face_form . >> ');">' . 'TEXT' . '</a>'; >> >> But I can't pass variable since it have double quotes: >> onlick="modalcommenttask(h3>Leave a Reply</h3><div class=" >> >> What the solution to pass html form from PHP to javascript function. > > But... I just explained how! You need to escape the string contents, and > you (obviously) need to wrap the string in quotes (double or single), > like you do in PHP. > > Since you're putting all of this inside an HTML attribute, so you'll > have to escape the HTML special characters as well (including quotes). > The htmlspecialchars() function does that for you. > > Anyway, having escaped HTML in an HTML attribute... brrr. Are you sure > this is the best way to do it? I just want to do modal window where I can make comment. For wordpress.
First
|
Prev
|
Pages: 1 2 Prev: Capture browser refresh using OnBeforeUnload event Next: A good opportunity to investment |