SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Evangelist Muller2's Avatar
    Join Date
    Feb 2005
    Location
    Oxford, UK
    Posts
    522
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    <textarea> new line

    Hi,

    How can I make a new line in a textarea?

    I have created these but neither work.
    Code:
    <textarea name="textarea">test<br>test2</textarea>
    
    <textarea name="textarea">test\ntest2</textarea>
    Can someone please help?

    Thanks,

    Al

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Code:
    <textarea name="textarea">test
    test2</textarea>

  3. #3
    SitePoint Evangelist Muller2's Avatar
    Join Date
    Feb 2005
    Location
    Oxford, UK
    Posts
    522
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok,

    That works, but I need it to accept values such as <br> or \n to create the newline.

    Can the field be made to except html code and proces it?

    Thanks,

    Al

  4. #4
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    Not unless you use entities or a sever side script.

  5. #5
    SitePoint Evangelist Muller2's Avatar
    Join Date
    Feb 2005
    Location
    Oxford, UK
    Posts
    522
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have

    Code:
    <textarea name="textarea">test\ntest2<br>test3</textarea>
    But that doesn't work make the line break with the <br>.



    Al

  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2003
    Location
    Coventry, UK
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Textarea is literally that. The values you put in there will be shown. If you 'forget' to end the tag, the rest of your HTML document will be displayed in the textarea.

    I'm not too sure why you'd want your users to type in "<br>" or "\n" but if you use a server side script you could make it so anytime they pressed enter (to create a new line) your script would interpret that as "<br>".

    Adam

  7. #7
    SitePoint Wizard bronze trophy Tyssen's Avatar
    Join Date
    Oct 2005
    Location
    Brisbane, QLD
    Posts
    4,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're trying to format text that already appears in a textarea then you should probably rethink what you're trying to do with it.

  8. #8
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <textarea>foo&#10;bar</textarea>
    Simon Pieters


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
  •