Form to JavaScript.

A

Andrew Koptyaev

Hello

I have Facebox javascript to output anything in modal window.
I want to display at modal box a form. Form - it is html code.
The form I do generate in the php code - for now just echo
all elements to buffer and then put buffer to variable.
I have a question - what way I can pass this variable with
form to script?
Or may be other solution to pass from php to javascript
a form?
 
R

rf

Andrew Koptyaev said:
Hello

I have Facebox javascript to output anything in modal window.
I want to display at modal box a form. Form - it is html code.
The form I do generate in the php code - for now just echo
all elements to buffer and then put buffer to variable.
I have a question - what way I can pass this variable with
form to script?
Or may be other solution to pass from php to javascript
a form?

42
 
A

Andrew Koptyaev

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.
 
A

Andrew Koptyaev

Stefan Weiss said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top