\n character within TEXTAREA tag

D

David

Hey,

I'm not quite sure where to post this, but I believe this is the most
appropriate place. I have a page I am creating that does a submission
within a hidden IFRAME every time someone adds an item to the shopping cart.
In this way, the entire page doesn't need to submit, only a hidden IFRAME,
and I can make sure that if the user decides to hit the back button at any
time, or even browse away from the page and come back, their shopping cart
will still be up to date and available for them to continue where they left
off. The way I accomplish this is by converting my shopping cart into a
text format that seperates the different information with \n characters (a
line-feed character), places the string into a TEXTAREA and submits the form
that is within the hidden IFRAME. Now, with IE6, when this gets submitted
and returned, the return comes back inside the TEXTAREA field, and all the
\n characters (line-feeds) get replaced with \r\n characters (carriage
return line feed). Unluckily, with Firefox, the return value is two \n
characters (\n\n). So, I figured I'd just try seperating with a \r\n to see
what happened. IE6 comes back with the same (\r\n) whereas Firefox returns
\r\n\n. Does anyone know how I can get around this issue? If I am posting
this in the wrong place, please direct me where this post should be.

Thanks,

David
 
R

Randy Webb

David said the following on 9/11/2005 10:56 PM:
Hey,

I'm not quite sure where to post this, but I believe this is the most
appropriate place. I have a page I am creating that does a submission
within a hidden IFRAME every time someone adds an item to the shopping cart.
In this way, the entire page doesn't need to submit, only a hidden IFRAME,
and I can make sure that if the user decides to hit the back button at any
time, or even browse away from the page and come back, their shopping cart
will still be up to date and available for them to continue where they left
off. The way I accomplish this is by converting my shopping cart into a
text format that seperates the different information with \n characters (a
line-feed character), places the string into a TEXTAREA and submits the form
that is within the hidden IFRAME. Now, with IE6, when this gets submitted
and returned, the return comes back inside the TEXTAREA field, and all the
\n characters (line-feeds) get replaced with \r\n characters (carriage
return line feed). Unluckily, with Firefox, the return value is two \n
characters (\n\n). So, I figured I'd just try seperating with a \r\n to see
what happened. IE6 comes back with the same (\r\n) whereas Firefox returns
\r\n\n. Does anyone know how I can get around this issue? If I am posting
this in the wrong place, please direct me where this post should be.

IE > \r\n
Firefox > \n\n

replace \r\n with \n
replace \n\n with \n

count the \n
 
D

David

The main reason I want to use \n is that I expect that the data that is
being delimited could contain characters such as '^'. I suppose I could
come up with one that is very unlikely though, something like two semicolons
';;' in a row or something such. However, since IE and Firefox have
predictable return values, I could just do as Randy Webb suggested by
replacing \n\n with \n and \r\n with \n and then splitting by that. The
only problem here is that since I am hoping to support a myriad of browsers
(particularly Netscape Navigator, Opera, and Safari), not just IE and
Firefox, what do they all return for a \n? Also, would it be possible to
use a \t character or vertical-tab character to split with?

Thanks,

David
 
A

ASM

David said:
I am hoping to support a myriad of browsers
(particularly Netscape Navigator, Opera, and Safari), not just IE and
Firefox, what do they all return for a \n?

never I got problems with \n (on my Mac, NC4 included)
Also, would it be possible to
use a \t character or vertical-tab character to split with?

on my idea you can use what you want (§ $ £ (|) ◊ ¿? ... )
 
R

RobG

David said:
The main reason I want to use \n is that I expect that the data that is
being delimited could contain characters such as '^'. I suppose I could
come up with one that is very unlikely though, something like two semicolons
';;' in a row or something such. However, since IE and Firefox have
predictable return values, I could just do as Randy Webb suggested by
replacing \n\n with \n and \r\n with \n and then splitting by that. The
only problem here is that since I am hoping to support a myriad of browsers
(particularly Netscape Navigator, Opera, and Safari), not just IE and
Firefox, what do they all return for a \n? Also, would it be possible to
use a \t character or vertical-tab character to split with?

If ordinary delimited values are not suitable, use name/value pairs. If
that is not suitable, use an XML style format.

If you are unsure whether some of the characters are unsafe,
encode/decode the string and use a safe character for your delimiter (a
hint would be to mimic the form submission format and use '&' between
pairs and '=' between name and value).

This really has nothing to do with JavaScript.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top