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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying multiple long paragraphs w/out loosing format 1

Status
Not open for further replies.

southbeach

Programmer
Jan 22, 2008
879
0
0
US
Having an interesting problem showing content which is collected using <textarea> ...

When displaying data, I am loosing the format used when data was typed (blank lines, paragraphs, ...). Everything is grouped together like a long single line.

If I use <pre></pre>, the content then goes beyond my intended display area overlapping across my right most layer.

What is the trick to getting this fixed?

Thanks!


--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
 
HTML is white space agnostic -- meaning that it understands any number of spaces and line breaks as a single space. If you look at the source code of your display page, you will see that all the spaces and paragraph lines are still there. To make the spaces appear on the actual HTML page you would have to:

1. Wrap the text in pre tags. You have already seen how that sometimes does not produce wanted results.
2. Use a function to add HTML line breaks where appropriate. In PHP you have a pre-built function that does that: nl2br()
3. Use a rich content editor such as TinyMCE or FCKEditor which will produce rich HTML instead of a simple text.

For your problem, solution #2 might work best.

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
vragabond,

Thanks so much for your time and such elegant reply. You were right, #2 was the solution.

#3 is one on my 'To Do' list - I have been meaning to start using fckEditor in my pages in lieu of using <textarea> tags.

Again, thank you for your help!


--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top