Turn javascript input into php-string
<p>I found this script for making a preview somewhat similar to the one used here on stackoverflow. When users have typed in the post I would like it to be converted into a php-string even before being showed in preview. This will be in order to use the mysql_real_escape_string as well as other things.</p>

<p>How do I make it into a php-string before showing? And it would also be very nice to know how to make it show again after I have escaped the string.</p>

<p>It contains essentially contain these two parts of code </p>

<p>1</p>

<pre><code>&lt;script type="text/javascript"&gt;
    function preview(field) {
        var p = document.getElementById('input_exercise');
        p.innerHTML = field.value;
    }

&lt;/script&gt;
</code></pre>

<p>2</p>

<pre><code>&lt;textarea style="width:500px; height:150px;" onkeypress="preview(this);"&gt;&lt;/textarea&gt;
&lt;p id="input_exercise"&gt;&lt;/p&gt;
</code></pre>

<p>Thanks</p>
