Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

having issue with carriage return from textarea on html page... 1

Status
Not open for further replies.

spewn

Programmer
May 7, 2001
1,034
I have a form that has a textarea. Users can type info into the textarea, and hit return when they need to create a new paragraph.

Then I have a perl script that pulls the info from textarea, stores in variable, then puts that variable in a mail script (using sendmail).

It works, but not exactly as it should.

If the user types in:

[textarea]
Here we have a story about a snake and a rabbit.

The rabbit runs to the snake.

The snake eats the rabbit.
[/textarea]

Once I capture that and put in sendmail script, the email shows the text as:


Here we have a story about a snake and a rabbit.


The rabbit runs to the snake.


The snake eats the rabbit.


As you can see, when I get the email, there are double returns where the user has pressed return.

I've tried escaping the textarea value, then unescaping the value when I put it in the email, but to no avail.

This is driving me crazy. I can store it in a database, and it stores correctly, but once it goes into the email, it comes to me double spaced.

Any ideas?

- g
 
The textarea tag might be adding \r\n or only \n to the end of each line break. You can try this on the variable that stores the text:

$var =~ s/\r?\n/\n/g;

Then put it into sendmail and see if it helps.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Perfect.

Thanks...very much appreciated!

I was going crazy.

- g
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top