• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3707
  • Last Modified:

How to insert line break into a TextArea control

Greetings everyone,

This is probably a cheap one, for that I apologize.

I will like to insert a br into a textArea so that when I hit then return key, the next text begins on a new line.
For instance, if I  have the following text:  Hello, World!
I am Christopher Columbus and I discovered America.

I would like "I am Christopher Columbus and I discovered America to start on a new line.

So far, everying is wrapping naturally which is fine but I want to be able to begin a new paragraph on a new line.

Can someone please help?

Comments: <textarea cols="20" rows="8" name="comments" maxlength="200" WRAP="Virtual"> </textarea>

thanks much in advance
  • 5
  • 2
1 Solution

just set the multiline property of the textarea.

fyi; no html elements are used in a text area, when you hit enter a line break character is inserted, instead of a <br>

good luck
oh, a text area is always multiline.. so it should already go to the next line when you hit <enter>

just see the comment textarea on this question page source in experts exchange,

        <textarea id="text" name="text" rows="15" cols="60" class="rightEdge"></textarea>

perhaps you have something on your form interfaring with your <enter> key?
nigermanAuthor Commented:
Well this occurs on details page - the page the displays info you enter on the textArea.

Here is that code and who knows what could be interferring with it.

<table width=100% cellspacing=10 valign=top ID="Table2">
             <P align=left><STRONG><FONT face=Arial></FONT></STRONG>&nbsp;</P>
                              '... create and open connection ...
                            Set conn = Server.CreateObject("ADODB.Connection")
                             conn.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
                            "DATA SOURCE=" & server.mappath("Database/SThom.mdb")
                            id = request("newsID")
                            Set RS = conn.Execute("SELECT details FROM tblAnnouncements WHERE newsID=" & id )
                               Response.Write RS(0)

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Ah it's the generation phase of the page. I thought you were refering to runtime when you said 'hit enter'.

So, the code you sent is correct, you don't need to replace -new line- characters with <br> tags when generating a <textarea>, since it already uses -new line-s.  So it looks like the problem is with the recorded values, have you checked the data to see if it has -new line- characters?
if the data doesn't contain new lines, it's probably related to your data retrieval page, so you'll have to modify your code on data retrieval to store the data without replacing / removing -line break- characters, and everything will work fine.

good luck
nigermanAuthor Commented:
thank you very much MrRobot.

Sorry for late response.

my kids (2 boys) are in first and second grades and today is their school's fall cleanup day. I had to rush to assist with cleaning up the property, hence the late response.
you're welcome nigerman =))

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now