Form newline issue
<p>I am sending a form with a notes field to an Oracle database and then displaying the notes. New notes can be added, and they will be appended to the previous note.</p>

<p>The problem I have is with the newline that I am inserting at the beginning of each notes update. I am sending notes updates to the database with a javascript in this manner: <code>oldNote + "\n" + date + " " + username + ": " + newNote;</code>.</p>

<p>This is the php part:</p>

<pre><code>echo "&lt;input class='button' type='button' id='Save' name='saveInteraction' onclick=\"saveInteractionInfo('$oldNote', '$date', '$username', '$interactionId', '$seqNum');\" value='Update'/&gt;";
</code></pre>

<p>This is the entire javascript function:</p>

<pre><code>function saveInteractionInfo(oldNote, date, username, interactionId, seqNum) {
    var formData = {};
    formData['interactionId'] = interactionId;
    formData['seqNum'] = seqNum;
    formData['notes'] = oldNote + "\n" + date + " " + username + ": " + document.all.notes.value;
    trxId = readCookie("transactionId");
    if(trxId)
        formData["transactionId"] = trxId;
    var respFunc = function(par1,par2,par3,par4) { postUpdateInteractionNotesResponseHandler(par1,par2,par3,par4); };
    var errorFunc = function(reqId) { return showErrorCaseHandler(reqId); };
    ajaxPostRequest("Interactions.php",formData,"Update Interaction Notes.","subExtra",respFunc,errorFunc);
}
</code></pre>

<p>Updating the notes works at it should, but when trying to update it for the second time I get an error in Firebug: <code>unterminated string literal: saveInteractionInfo('Test</code>, where saveInteractionInfo is the function I am passing the notes to and 'Test' is the form value. So the error occurs when the newline is passed to the function.</p>

<p>Any suggestions how I could get this working?</p>

<p><em>UPDATE</em> So the problem is that the $oldNote has line breaks (\n) in it, which stops it from passing the data to the javascript function.
The tag now:</p>

<pre><code>&lt;input class='button' type='button' id='Save' name='saveInteraction' onclick="saveInteractionInfo('fdsfsfsf
dfdfdf
gdfgdg', '13/09/2011 16:11:13', 'blaha01', '7038245', '2');" value='Update'/&gt;
</code></pre>

<p>The tag as it should be:</p>

<pre><code>&lt;input class='button' type='button' id='Save' name='saveInteraction' onclick="saveInteractionInfo('fdsfsfsfdfdfdfgdfgdg', '13/09/2011 16:11:13', 'blaha01', '7038245', '2');" value='Update'/&gt;
</code></pre>

<p>Any other suggestions?</p>
