473,395 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

replacing carriage returns?

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
Jul 22 '05 #1
2 1766

Jerome wrote:
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>")%>


don't use Chr(13), use

vbcrLF

Jul 22 '05 #2
"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.
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: yawnmoth | last post by:
so... i'm trying to remove all carriage returns in the input i get from GET, and am trying to replace them with three dots... however, this never seems to work... i'm still getting carriage...
7
by: Rob Meade | last post by:
Hi all, Been a long time since I've been here... /me waves to all.. Ok - my conundrum.. I have a form where a user can enter text and BB codes...for example:
4
by: Les Juby | last post by:
Can someone please help with a suggestion as to how I can keep the formatting (carriage returns) that the user enters into a memo field and then display that later. I figured I might be able to...
4
by: John | last post by:
Hi How can I replace characters like carriage return and double quotes from strings? Thanks Regards
6
by: Tbone | last post by:
I'm changing our order confimation from a plain text to HTML. The original setup of this had carriage returns between line items. These are not interpreted by HTML so all the line items run...
5
by: Mario Vargas | last post by:
How do I replace carriage returns with <br /> in Visual Basic .NET? I know this is easy to do with C# by simply calling myNewString = myString.Replace( "\n", "<br />" ); Thank you for your...
2
by: Matt Mercer | last post by:
Hi all, I am having a frustration problem, and I have read about 25 newsgroup postings that do not have a satisfying answer :) The problem appears to be common where carriage returns are lost...
7
by: mattrapoport | last post by:
I have a page with a div on it. The div displays a user comment. When the user logs into this page, their current comment is pulled from a db and displayed in the div. The user can edit the...
1
by: asturt | last post by:
I have a string with multiple carriage returns in it. I need to remove the second carriage return but leave all the rest. Anyone know of a function that will do this? I've come up with this: ...
0
by: markus.shure | last post by:
Hi, I'm noticed a problem testing a JAX-WS client with a WSE server. The JAX-WS client adds carriage returns to a SOAP header element that is signed. This causes the WSE server to raise an...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.