How to get a line feed into a textarea

Posted on 2005-04-15
Medium Priority
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

ID: 13794346
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.


Author Comment

by:CIC Admin
ID: 13806694
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

ID: 13807621
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

Michel Plungjan earned 300 total points
ID: 14772158
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

840 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