...

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



stryper
04-08-2003, 07: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.

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



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


Or PHP replace...



<?php

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

?>


Or there is a PHP function that automatically does this.



<?php

nl2br($form_value);

?>


Hope this helps.

thox
04-10-2003, 04: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.

missing-score
04-10-2003, 05: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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum