Display problem for textarea data

liunx

Guest
I have created textarea to get input : <br />
<br />
<textarea name="action" cols="50" rows="5"></textarea> <br />
If I input with the following : <br />
111 <br />
222 <br />
333 <br />
<br />
When I try to display the the result on a table ( eg. <td>$action</td> ), it displays in one line with no linebreak, eg. : <br />
111222333 <br />
<br />
Any idea to display it as input value with linebreak ?<!--content-->Try to do a search/replace on the string data (the text area data submitted). You are looking for any combination of '\r\n\','\n','\r' and should replace them with '<BR />' before outputting to text.<br />
<br />
Most scripting languages support somekind of string replacement using regular expressions which seems the most logical way to go ahead with this task.<br />
<br />
If you are using PHP you can use the nl2br function (new line to html BR):<br />
<br />
<!-- m --><a class="postlink" href="http://www.php.net/manual/en/function.nl2br.php">http://www.php.net/manual/en/function.nl2br.php</a><!-- m --><br />
<br />
$action = ereg_replace("(\r\n|\n|\r)", "<br />", $action);<!--content-->Thank you so much. It works exactly what I want.<!--content-->
 
Back
Top