|
 |
asp_databases thread: Problem replacing Chr(13)
Message #1 by jmuldoon@q... on Mon, 23 Jul 2001 12:43:08
|
|
When users use <ENTER> to start a new line in a form text box, it doesn't
show a new line in the HTML output page. Here's what I did to solve the
problem.
Comm =Replace(Comm, Chr(13), "<br>")
That works fine. Now a new line shows up in the HTML. However, whatever Chr
(13) represents apparently isn't replaced because, if a user calls that
record up and submits the form again, another <br> is added. What am I
doing wrong here?
Thanks,
Joe
Message #2 by "Dallas Martin" <dmartin@z...> on Mon, 23 Jul 2001 07:52:55 -0400
|
|
It seems that the user is being allowed to re-edit the same data. Thus the
user's habit of pressing the <ENTER> key continues. I think it may be best
to simply remove both the <BR> and the CHR(13) from the text everytime it
must be stored in the database. When it must be displayed in a text box,
let HTML handle the wrapping.
Dallas
----- Original Message -----
From: <jmuldoon@q...>
To: "ASP Databases" <asp_databases@p...>
Sent: Monday, July 23, 2001 12:43 PM
Subject: [asp_databases] Problem replacing Chr(13)
> When users use <ENTER> to start a new line in a form text box, it doesn't
> show a new line in the HTML output page. Here's what I did to solve the
> problem.
>
> Comm =Replace(Comm, Chr(13), "<br>")
>
> That works fine. Now a new line shows up in the HTML. However, whatever
Chr
> (13) represents apparently isn't replaced because, if a user calls that
> record up and submits the form again, another <br> is added. What am I
> doing wrong here?
>
> Thanks,
>
> Joe
Message #3 by Steve Carter <Steve.Carter@t...> on Mon, 23 Jul 2001 13:27:37 +0100
|
|
If you don't want to keep the user-entered new lines, then go with
Dallas Martin's suggestion. If you do, then a two-part suggestion:
1) Instead of replacing Chr(13) with "<BR>", replace vbCrLf
2) Don't replace in situ: instead of
Comm =3DReplace(Comm, vbCrLf, "<br>")
use
CommDisplay =3DReplace(Comm, vbCrLf, "<br>")
and print out CommDisplay, but store Comm in the DB. You need to
remember to Replace the vbCrLF every time you display it, but at least you
are storing what was typed and thus can conjure it up again whenever you
need.
> -----Original Message-----
> From: jmuldoon@q... [mailto:jmuldoon@q...]
> Sent: 23 July 2001 13:43
> To: ASP Databases
> Subject: [asp_databases] Problem replacing Chr(13)
>
>
> When users use <ENTER> to start a new line in a form text
> box, it doesn't
> show a new line in the HTML output page. Here's what I did to
> solve the
> problem.
>
> Comm =3DReplace(Comm, Chr(13), "<br>")
>
> That works fine. Now a new line shows up in the HTML.
> However, whatever Chr
> (13) represents apparently isn't replaced because, if a user
> calls that
> record up and submits the form again, another <br> is added.
> What am I
> doing wrong here?
>
> Thanks,
>
> Joe
>
Message #4 by "raghu bejgum" <raghu_hale@h...> on Mon, 23 Jul 2001 18:24:52 +0530
|
|
Hi Joe,
I think what ever u r doing is bit wrong.. becoz on server side u have to
trap vbcrlf instead of chr10.. then ur problem will be solved becoz i have
done some thing similar to ur requirement.. and i have trapped vbcrlf and
its working fine... If u still have any problem pls lemme know
Raghavendra.B
S/w Engg
Globarena Group...
>From: jmuldoon@q...
>Reply-To: "ASP Databases" <asp_databases@p...>
>To: "ASP Databases" <asp_databases@p...>
>Subject: [asp_databases] Problem replacing Chr(13)
>Date: Mon, 23 Jul 2001 12:43:08
>
>When users use <ENTER> to start a new line in a form text box, it doesn't
>show a new line in the HTML output page. Here's what I did to solve the
>problem.
>
>Comm =Replace(Comm, Chr(13), "<br>")
>
>That works fine. Now a new line shows up in the HTML. However, whatever Chr
>(13) represents apparently isn't replaced because, if a user calls that
>record up and submits the form again, another <br> is added. What am I
>doing wrong here?
>
>Thanks,
>
>Joe
Message #5 by "Ken Schaefer" <ken@a...> on Tue, 24 Jul 2001 14:19:53 +1000
|
|
Chr(13) is a line feed. What you actually probably looking for is to replace
Chr(10) (carriage return) + Chr(13) (line feed). VBScript provides a handy
way to address this with the built in constant: vbCrLf
Now, when the user presses <enter>, you get a vbCrLf.
When you want to display this on the page, a browser doesn't render vbCrLf -
it only uses HTML tags to render things, so you need to replace vbCrLf with
an equivalent HTML tag: <br>
However, you probably don't want to store this HTML tag in the database.
Store the original text (with vbCrLf) in the database. Replace vbCrLf with
<br> when you display on a webpage.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <jmuldoon@q...>
Subject: [asp_databases] Problem replacing Chr(13)
: When users use <ENTER> to start a new line in a form text box, it doesn't
: show a new line in the HTML output page. Here's what I did to solve the
: problem.
:
: Comm =Replace(Comm, Chr(13), "<br>")
:
: That works fine. Now a new line shows up in the HTML. However, whatever
Chr
: (13) represents apparently isn't replaced because, if a user calls that
: record up and submits the form again, another <br> is added. What am I
: doing wrong here?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Message #6 by jmuldoon@q... on Tue, 24 Jul 2001 03:23:23
|
|
Raghavendra and Steve:
You solved my problem. I don't know where I got the Chr(13), probably out
of one of my Wrox books, though. Anyhow, it's working fine, even when the
<br> is stored in the database. Doesn't cauuse any problems when user
brings in info up and resubmits the form.
Thanks guys.
Joe
> Hi Joe,
> I think what ever u r doing is bit wrong.. becoz on server side u have
to
> trap vbcrlf instead of chr10.. then ur problem will be solved becoz i
have
> done some thing similar to ur requirement.. and i have trapped vbcrlf
and
> its working fine... If u still have any problem pls lemme know
>
> Raghavendra.B
> S/w Engg
> Globarena Group...
>
>
>
> >From: jmuldoon@q...
> >Reply-To: "ASP Databases" <asp_databases@p...>
> >To: "ASP Databases" <asp_databases@p...>
> >Subject: [asp_databases] Problem replacing Chr(13)
> >Date: Mon, 23 Jul 2001 12:43:08
> >
> >When users use <ENTER> to start a new line in a form text box, it
doesn't
> >show a new line in the HTML output page. Here's what I did to solve the
> >problem.
> >
> >Comm =Replace(Comm, Chr(13), "<br>")
> >
> >That works fine. Now a new line shows up in the HTML. However, whatever
Chr
> >(13) represents apparently isn't replaced because, if a user calls that
> >record up and submits the form again, another <br> is added. What am I
> >doing wrong here?
> >
> >Thanks,
> >
> >Joe
>
Message #7 by jmuldoon@q... on Tue, 24 Jul 2001 03:19:44
|
|
Dallas:
What happens is, the user might call up the form to change any of a number
of different items. The extra <br>'s come in on resubmit. These
replacements come in a text box where I want the users new line to persist
rather than continuing a line that HTML wraps. The suggestions to drop Chr
(13) in favor of vbCrLf solved the problem.
Thanks for the input.
Joe
> It seems that the user is being allowed to re-edit the same data. Thus
the
> user's habit of pressing the <ENTER> key continues. I think it may be
best
> to simply remove both the <BR> and the CHR(13) from the text everytime it
> must be stored in the database. When it must be displayed in a text box,
> let HTML handle the wrapping.
>
> Dallas
>
>
>
>
>
> ----- Original Message -----
> From: <jmuldoon@q...>
> To: "ASP Databases" <asp_databases@p...>
> Sent: Monday, July 23, 2001 12:43 PM
> Subject: [asp_databases] Problem replacing Chr(13)
>
>
> > When users use <ENTER> to start a new line in a form text box, it
doesn't
> > show a new line in the HTML output page. Here's what I did to solve the
> > problem.
> >
> > Comm =Replace(Comm, Chr(13), "<br>")
> >
> > That works fine. Now a new line shows up in the HTML. However, whatever
> Chr
> > (13) represents apparently isn't replaced because, if a user calls that
> > record up and submits the form again, another <br> is added. What am I
> > doing wrong here?
> >
> > Thanks,
> >
> > Joe
Message #8 by "Ken Schaefer" <ken@a...> on Tue, 24 Jul 2001 19:06:41 +1000
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <jmuldoon@q...>
Subject: [asp_databases] Re: Problem replacing Chr(13)
: Anyhow, it's working fine, even when the <br> is stored in
: the database. Doesn't cauuse any problems when user
: brings in info up and resubmits the form.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The problem with storing <br> in the database is that if you want to use the
data somewhere else (eg you need to print a report in Access or something),
the <br> will end up a literal text in the report.
IMHO, Better to store vbCrLf in the database, and then replace on the fly
when presenting that data in a webpage.
Cheers
Ken
Message #9 by jmuldoon@q... on Wed, 25 Jul 2001 18:31:43
|
|
Ken:
Thanks for all your info and persistence in pointing out issues I was
neglecting. Your explanation was crystal clear and will help me avoid
hassles in the future.
Joe
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> From: <jmuldoon@q...>
> Subject: [asp_databases] Re: Problem replacing Chr(13)
>
>
> : Anyhow, it's working fine, even when the <br> is stored in
> : the database. Doesn't cauuse any problems when user
> : brings in info up and resubmits the form.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> The problem with storing <br> in the database is that if you want to use
the
> data somewhere else (eg you need to print a report in Access or
something),
> the <br> will end up a literal text in the report.
>
> IMHO, Better to store vbCrLf in the database, and then replace on the fly
> when presenting that data in a webpage.
>
> Cheers
> Ken
>
>
|
|
 |