"Jerome" <no****@nospam.com> wrote in message
news:OR**************@TK2MSFTNGP09.phx.gbl...
Hi, I know this is an old question but I don't find the solution on the
'net ...
The user enters his data into a multiline textarea field.
The data is saved in a TEXT field in a database on a SQL Server.
I want to display that data now, but the carriage returns should be
replaced with <br>! Otherwise the text doesn't have paragraphs.
How do I do that?
This hasn't worked:
<% response.write replace(rsRappAct.Fields.Item("texte").Value, Chr(13),
"<BR>")%>
Thanks a lot!
Jerome
<% Response.Write Replace(rsRappAct("texte"),vbCrLf,"<br>")%>
Somewhat off-topic but may be of interest ....
Here's an example of a client-side textarea cleanup I use.
It removes all leading and trailing CrLf's and spaces.
It also converts 3 or more CrLf's to just two.
<html>
<head>
<title>CrLf_Fix.htm</title>
<script type="text/javascript">
function CrLf() {
var rex1 = /^[\r\n\s*]+|[\r\n\s*]+$/g; // trim CrLf's
var rex2 = /(\r\n\s*){2,}/g; // 2max CrLf's
var data = document.forms[0].data.value;
if (data != "") {
var what;
//* remove leading and trailing CrLf's from "textarea":
what = data.replace(rex1,"");
//* replace 3+ consecutive CrLf's with 2 in "textarea":
what = what.replace(rex2,"\r\n\r\n");
if (what != data) document.forms[0].data.value = what;
}
}
</script>
</head>
<body>
<form>
<textarea name="data" cols="52" rows="20"></textarea>
<br>
<input type="button" value="Remove leading, trailing, and multiple CrLf's"
onclick="CrLf()">
<input type="reset" value="Clear">
</form>
</body>
</html>
It's not perfect (suggestions are welcome) but it helps reduce garbage
input.