Missing text on saving

  •  01-24-2006, 7:45 PM

    Missing text on saving

    In the text window we are loosing text when saving if there are more than one paragraph returns used.
     
    We are using DOM with javascript to:
    1) copy the text window contents into a variable
    2) asynchronous save of the variable
    3) return saved result

    Looking at the HTML contents of the variable there is "<div>ampersand#160;  </div>" (note I needed to type out & to keep the information) in place of the paragraph returns.  On sending this to be saved these are lost along with any text after them.

    Any ideas what is happening and how I can easily solve it?

    Here's the relevant code:

    var editor1 = el("CE_Editor1_ID");
    myNote = editor1.getHTML();
    SaveNote(myNote, Id);

    function SaveNote(myNote, Id)
    {
     var mydate = new Date();
     clearParams();
     addParam("Id", Id);
     addParam("noteContent", myNote);
     addParam("dateTime_Modified", paramDateString(mydate));
     doAsyncCallback("Visit.SaveNote", SaveNoteSuccess, SaveNoteError);   
    }


    Thanks BS

    PS

    I've discovered that a range of other characters do the same thing (eg ", &, +, <, >).  By copying the contents of the text area into a variable I must be effecting cute editor's treatment of special characters. 
    These seem to be "character references".  Any way of easily dealing with them - other than relacing them as below - seems to work for most but not all, eg &
     
    myNote = myNote.replace(/&quot;/g, '"');
    myNote = myNote.replace(/&amp;/g, "and");
    myNote = myNote.replace(/&lt;/g, "<");
    myNote = myNote.replace(/&gt;/g, ">");   
    myNote = myNote.replace(/'/g, "'");
    myNote = myNote.replace(/ /g, "<br>");
View Complete Thread