Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,994
    Thanks
    120
    Thanked 76 Times in 76 Posts

    what is new line in <textarea>

    1.I type multiline (hiting enter) into html textarea.
    2. save as it is, to MYSQL, there it becomes one single line
    3. pick it up in java from database, there it looks ok, multiline, in debuger
    4. send back to client , again one single line !?

    tryed, before sending to client:
    Code:
    s = s.replaceAll("$","</BR>");
    but looks it is realy one single line coz </BR> appears only at the end of s.

    How to handle that ?
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #2
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,994
    Thanks
    120
    Thanked 76 Times in 76 Posts
    Code:
    //works
    s=s.replace("\n","<BR>");
    //does not    
    s=s.replace(System.getProperty("line.separator"),"<BR>");
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Are you using java or javascript?
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #4
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,994
    Thanks
    120
    Thanked 76 Times in 76 Posts
    java of course,
    Code:
    s=s.replace("\n","<BR>");
    works on linux and win, so this is database dependant.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #5
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    It looks like java has an nl2br method. You may want to look into it.

    http://njet.org/api/anvil/util/Conversions.html

    I couldn't find much documentation on the nl2br method. Also have you tried this?
    Code:
    s=s.replaceAll(System.getProperty("line.separator"),"<BR>");
    Last edited by _Aerospace_Eng_; 02-25-2010 at 03:25 PM.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •