View Full Version : showing text captured with a text area input

04-08-2003, 06:43 PM
hello, i have this problem in a page i get long user text with a input text area box, after that i save it in a Mysql table and later i show that text in a browser, but if the user insert spacen between paragraph it doesnt save them it show the text as a long single line of thex, how can i get this spaces (\n) to be showed as user inserts the text.

04-08-2003, 07:00 PM
You could do a javascript replace

document.whatever.textarea.value.replace(/\n/g,'<br />');

Or PHP replace...


ereg_replace("\n",'<br />',$form_value);


Or there is a PHP function that automatically does this.




Hope this helps.

04-10-2003, 03:04 PM
you can also use <pre></pre> for displaying preformatted text. then you could also add some nice css to stop it from looking too out of place.

04-10-2003, 04:51 PM
I forgot about that.

I have never actually used the <pre> tag before, even though I know what it does. Guess thats just me :D