line breaks via. javascript

Discussion in 'HTML & Website Design' started by vitaminp, Apr 23, 2007.

  1. #1
    i have a few multi-line form fields that i sent to php via. javascript (ajax)

    however it seems the line breaks are missing when it is put to the javascript, is there any work around to this?

    e.g.

    my name is
    paul

    ==>

    my name is paul
     
    vitaminp, Apr 23, 2007 IP
  2. Louis11

    Louis11 Active Member

    Messages:
    783
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    70
    #2
    Simple!! :)

    The problem is you're passing the carriage returns and they aren't being interpretted as line breaks. You need to modify the input to pass these carriage returns as <br />'s.

    Your solution is: nl2br()
    Hope that helps :D
     
    Louis11, Apr 23, 2007 IP
  3. vitaminp

    vitaminp Peon

    Messages:
    202
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yeah i use nl2br however by the time they get to the php script the carriage returns have already been discarded
     
    vitaminp, Apr 24, 2007 IP
  4. Louis11

    Louis11 Active Member

    Messages:
    783
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    70
    #4
    Show us some code :) Are you sure they are being discarded or are you just looking for the wrong carriage return?
     
    Louis11, Apr 24, 2007 IP