473,473 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

\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 5701
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: reneecccwest | last post by:
Please discard the previous message. It should be characters instead of words. can anybody share the code for a character counter for the textarea user input? what if max characters are 256? ...
2
by: Jon | last post by:
All, I'm currently working with a PHP-based CMS application, and am begining to put the finishing touches on it via Javascript validation. Currently, I'm using fairly standard methods of...
6
by: @sh | last post by:
Guys, Working on a function to alert the user to too many characters being entered into a text area, I've put together this function so far borrowing bits from resource websites... function...
4
by: mantrid | last post by:
Hello I have been getting strange behaviour when using ' in by textboxes. eg inputting the following this is some test text ' and so is this is saved to the mysql database ok as this is...
23
by: Angus | last post by:
Hello I have a DIV with various elements eg: <div ARID="8" ARType="Char" ARDBN="Short Description"> <label class="label f9" for="arid8"Short Description</label> <textarea class="text sr "...
3
by: Jeff | last post by:
I have had this function work perfectly in IE and am trying to get it to work in Firefox. I have seen plenty of questions and answers on the web for how to get and check the key pressed but nothing...
16
by: bgold12 | last post by:
Will newlines ever be standardized? I recently discovered that in a textarea, internet explorer adds \r\n for every newline you enter, while firefox adds \n. I know \r is also used in some...
4
by: simon2x1 | last post by:
i have a text box i mean textarea(<textarea></textarea>) in my page i want to restrict user no to post more than 40 character how can i do that
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.