How to get a line feed into a textarea

Posted on 2005-04-15
Last Modified: 2012-05-05
I am using a web application I have little control over.  Using a web interface, I build a page by filling in a number of standard one-line input fields.  One of these fields will ultimately be displayed in a future page as a textarea object.  I will not be able to have any control such as searching and replacing text in a field as some other solutions recommend.  I need to be able to input something into this input field that when displayed as a textarea object will act as a line feed.  I have tried entering the <BR> tag, but it just gets displayed in the textarea box rather than actually dropping down to the next line.

Seems like a long shot since my hands are somewhat tied, but I thought I would give it a shot.

Question by:CIC Admin
    LVL 32

    Expert Comment

    In textareas, you have to use physical linebreaks.


    <textarea rows="5" cols="50">Line 1
    Line 2
    Line 3

    And if you're pulling data from a database, you could convert characters such as <br> into a newline sign (\n) before showing them in the textarea.

    LVL 5

    Author Comment

    by:CIC Admin
    Yes, but I don't have access to the code, so I cannot perform any conversions.  I need to be able to enter something in the input text field that will later show up as a line feed when displayed in the text area.  

    Still somewhat dubious that this is possible,
    LVL 14

    Expert Comment

    It looks like they are converting your input into HTML entities, so <BR> gets changed to &lt;BR&gt;

    It is possible that this also will be converted, but along the lines of what Batalf suggested, you might try to place a carriage return and line feed into your input where you want newlines:

    LVL 75

    Accepted Solution

    the javascript linefeed is \n
    It cannot be entered by hand
    Input fields do not accept linefeeds.
    If you cannot manipulate the fields before they end up in the textarea, then forget it

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
    This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
    In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
    In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now