SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how do you add a NEWLINE a textarea?

    I am trying to take the value of the textarea field, f1, and add from a select pull down menu = multiple additions are possible.

    var x=document.getElementById('selectbox1')
    ...
    document.forms[0].elements['f1'].value = document.forms[0].elements['f1'].value + x.options[x.selectedIndex].text;

    I need to a /r/n or something like that but when I try it, it adds "/r/n" rather than a new line.

    So, how do I add a new line to a textarea?

  2. #2
    SitePoint Addict
    Join Date
    Nov 2005
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The return and linefeed characters have a backslash, not a forward slash. Should be "\r\n". But just a newline should suffice in JavaScript ("\n").

  3. #3
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, it was actually, \n and it wworks now - thanks


Bookmarks

Posting Permissions

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