1

So I'm ajax storing mulit line information from a TEXTAREA html field into a MySQL TEXT column.

When I recover the Data and insert it back into the TEXTAREA it comes back as one single line.

I'm using JQUERY with a simple

    $(document).on('blur','.updateblur ',function(event){
  //var whichstory = $(this).parent().find("input").attr('name');
  console.log($(this).val());
  var command = $(this).attr("id") ;
  var value = $(this).val() ;
            $.post('admin/storycontrol/'+whichstory+'/'+command+'/'+value+'/', function(data){
                console.log(data);
          });    
});

So in the text area I have

Line 1
Line 2

I store it in the database

Return it from Jquery

and it appears in the textarea as:

Line 1 Line 2

I would like it to appear back in the text area as once I stored it.

Thanks

BostonMacOSX
  • 1,369
  • 2
  • 17
  • 38

2 Answers2

1

You need to substitute in carriage returns for line breaks.

Replace all the line breaks with \r\ns to paste in your <textarea>.

Jonathan Lam
  • 16,831
  • 17
  • 68
  • 94
0

You can save the text along with &#013;&#010; (ascii codes for cr,lf)

<textarea>
    hello &#013;&#010; world
</textarea>

http://jsfiddle.net/ypmecjut/1/

DinoMyte
  • 8,737
  • 1
  • 19
  • 26