473,498 Members | 310 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Linefeed problem from textarea -> variable

Good afternoon,

in a form a multiline textbox is defined:
<textarea name="text" cols="25" rows="3">This is the text.
this should be line 2</textarea>
In the textbox the linefeed is displayed correctly. Now I need to hand the
"value" property to a string variable like:
myString = document.forms[0].text.value;
In myString all linefeed commands have been deleted. Is it somehow possible
to keep the linefeed information ?
Thank you for any hint.
Best regards
Juergen Heyn, Wilhelmshaven, Germany
Jul 20 '05 #1
2 2026


Jürgen Heyn wrote:
in a form a multiline textbox is defined:
<textarea name="text" cols="25" rows="3">This is the text.
this should be line 2</textarea>
In the textbox the linefeed is displayed correctly. Now I need to hand the
"value" property to a string variable like:
myString = document.forms[0].text.value;
In myString all linefeed commands have been deleted. Is it somehow possible
to keep the linefeed information ?


How do you check for linefeeds? Maybe it is just that on your platform a
carriage is used? You should test
/\r\n|\r|n/g.test(document.forms[0].text.value)

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Martin Honnen wrote:
How do you check for linefeeds? Maybe it is just that on your platform a
carriage is used? You should test
/\r\n|\r|n/g.test(document.forms[0].text.value)

^^^^ ^^^^
The test can be corrected, simplified, and made standards compliant.
Either

/\r?\n|\r/g.test(document.forms[0].elements['text'].value)

or

/\r\n?|\n/g.test(document.forms[0].elements['text'].value)
PointedEars
Jul 23 '05 #3

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

Similar topics

5
2990
by: Jürgen Heyn | last post by:
Good afternoon, I would like to join several elements in one string. Every element should have its own line. After this I would like to display the string on a document. The following code...
3
5064
by: Wade G. Pemberton | last post by:
Help!: I use javascript to format repetitive data from a web page input FORM into a long string , and save it as lines of comma delimited data in a text file on a Unix server. The text...
1
3542
by: Volt | last post by:
is there any way to select and mark part of text in textarea by regular expression? i need to select the first string in textarea whitch is like xxxxx,xxx where x is any character
4
4221
by: TJS | last post by:
can the rows and columns of a textarea element with an id be changed on the fly ? if so is there an example ?
6
5961
by: wperry1 | last post by:
I am writing a small database utility to catalog all of my favorite ASM/JS/VBS... functions and scripts on an asp page. Everything is going smoothly except for one thing that I can't quite seem to...
1
2934
by: phpCodeHead | last post by:
I know that this sounds like something overly complex - because it is. However, if I can keep the user interface the way it is, my users will be ultra happy! That is the goal... In general, this...
3
4911
by: MikeK | last post by:
Ok, I've been noodling with this for several days now and I'm starting to go crazy. Does Apple's Safari browser support drag events on Textarea elements? The few specs and docs I've found seem to...
5
4756
by: a113n | last post by:
I have the following XSL code to handle textareas: <!-- Match TEXTAREA --> <xsl:template name="TEXTAREA" match="TEXTAREA"> <TEXTAREA ROWS="{@ROWS}" COLS="{@COLS}" NAME="{@NAME}"> <xsl:if...
1
2154
by: beary | last post by:
I need to populate a textarea from drop down box. There are a few "solutions" out there, but they seem to remove the first choice from the textarea when a second selection is made. So I need... 1)...
0
6998
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
7163
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,...
1
6884
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...
1
4904
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4586
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
3090
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
1416
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 ...
1
651
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
287
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.