Page 1 of 1

formatting output text from textarea

Posted: Fri Feb 18, 2005 4:43 am
by pleigh
hii there,

i would like to know how i can format the output text coming from the text area.i have a forum-like program, if i add a thread, type the message, i like to view the output like how it appeared when i typed it in the textarea.what happens to me is that everytime i type some words, strike the return/enter key, the output is not how it was typed but instead, the new line becomes a space. i am really confused,maybe i'll put an example.

i like
some text
some text
some text
to appear like the above format.

my problem is, when i do it(strike the return/enter key) after each some text word,this is how it appears:
some text some text sometext
i hope you guys can help me..

thanks

pleigh

Posted: Fri Feb 18, 2005 4:51 am
by Wayne
nl2br();

remember html only does what you tell it to, it does not respond to whitespace in strings unless you tell it.

Posted: Fri Feb 18, 2005 6:12 am
by jonemo
you could use <pre></pre> if you want to show whitespaces and tabs used in the textarea, but if you just want the kline breaks, then nl2br() is the right joice.

Posted: Mon Feb 21, 2005 3:42 am
by CoderGoblin
Or if you want to have enhanced options you could look for HTML Text Areas by

Googling for HTMLArea.

Another alternative is

http://www.kevinroth.com/rte/demo.htm

These might be overkill but I thought I'd let you know about them.