Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Converting line breaks to <br> in textarea output

Quote Reply
Converting line breaks to <br> in textarea output
I currently have HTML formatted turned off for the output of a column from a textarea by using <%escapeHTML ColumnName%>

Unfortunately, this gets rid of any line breaks the user may have put in their text. Is there a way to convert linebreaks to <br> tags?

I would have to stop using "escapeHTML" in order for the <br> tags to work, though, so would there be a way within the same mod to not allow any html codes except for <br> after the linebreaks are converted to <br> tags?

I have tried using the <pre> tag but it doesn't word wrap and it would be much better to allow certain HTML codes anyhow.

Any ideas? Thank you
Quote Reply
Re: [Dempsey] Converting line breaks to <br> in textarea output In reply to
Looks like I've found the solution using the <pre> tag to nicely wrap.

Call the data with:

Code:
<pre STYLE="font-size: 12; font-family:'arial'">
<%escapeHTML ColumnName%>
</pre>

In your header CSS put the following:

Code:
pre {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word;
}
Then, to make it work in IE, add a style to the table containing the data like this:

Code:
<table style="width: 100%; table-layout: fixed;">
It looks good and formats line breaks while disabling all other HTML.

I would still like to be able to allow for certain HTML tags like bolding, if anyone knows how?

Thanks