469,898 Members | 1,733 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

\n character within TEXTAREA tag

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
Sep 12 '05 #1
5 5581
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

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Sep 12 '05 #2
David wrote:
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


For historical reasons , ( cr/lf ) vs. ( lf ) often get mangled in
translation. Since nobody ever sees it , how about avoiding the whole
issue by picking a different delimiter, one that is less likely to be
mangled. I use a '^' in lue of '\n' in many things.

--
--.
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=-- C++,HTML/CSS,Javascript,TCP ...
--`
Sep 12 '05 #3
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
Sep 13 '05 #4
ASM
David wrote:
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 (§ $ £ (|) ◊ ¿? ... )
--
Stephane Moriaux et son [moins] vieux Mac
Sep 13 '05 #5
David wrote:
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.
--
Rob
Sep 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by reneecccwest | last post: by
6 posts views Thread by @sh | last post: by
4 posts views Thread by mantrid | last post: by
16 posts views Thread by bgold12 | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.