Using jQuery how can I set the contents of a textarea when the value from MySQL contains newlines
<p>To keep my code clean I am defaulting each of the elements of a form with jQuery.</p>

<p>i.e My form contains elements like this..</p>

<pre><code>&lt;input name="mobile" id="mobile" type="text" /&gt;
</code></pre>

<p>In my separate javascript file, I read data from MySQL, then use jQuery to set it, after the form is loaded..</p>

<pre><code>$('#mobile').val('07845 887766');
</code></pre>

<p>this value is read from MySQL and I generate the code like this, in PHP..</p>

<pre><code>echo "\n $('#mobile').val('".$user['mobile']."');";
</code></pre>

<p>This works fine, but the problem lies when there is a textarea field..</p>

<pre><code>&lt;textarea name="notes" id="notes" &gt;&lt;/textarea&gt;

echo "\n $('#notes').html('TEST');";
</code></pre>

<p>This works fine, but when I replace it with the data from a database, which can contain newlines, I get a javascript error.</p>

<pre><code>echo "\n $('#notes').html('".$user['notes']."');";
</code></pre>

<p>This could produce this code (Actual values...)</p>

<pre><code>$("#notes").html("INSERT INTO action    (
                    inputdate,
                )
                VALUES ()");
</code></pre>

<p>Which gives an error.  "unterminated string literal"</p>
