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

Home Posts Topics Members FAQ

Retrieve the value in TextArea with the newline preserved.

Hi,
I am trying to retrieved the value of the textarea with the newline
preserved without having to submit the form to the server. Does anyone
knows how to? I tried soft and hard wrap but both does not seems to
affect the input in anyway.

Example :
<form name=frm>
<textarea name=ta wrap="soft"></textarea>
</form>
<script language=javascript>
alert(document.frm.ta.value) // <-- the alerted value should look
exactly as what is entered in the textbox.
</script>

regards,
Chin
Jul 23 '05 #1
5 11201
"chin" <ch****@hotmail.com> wrote in message
news:f0*************************@posting.google.co m...
Hi,
I am trying to retrieved the value of the textarea with the newline
preserved without having to submit the form to the server. Does anyone
knows how to? I tried soft and hard wrap but both does not seems to
affect the input in anyway.

Example :
<form name=frm>
<textarea name=ta wrap="soft"></textarea>
</form>
<script language=javascript>
alert(document.frm.ta.value) // <-- the alerted value should look
exactly as what is entered in the textbox.
</script>

regards,
Chin


This works for me.

<html>
<head>
<title>textline.htm</title>
<script type="text/javascript">
function text() {
alert(document.frm.ta.value)
}
</script>
</head>
<body>
<form name=frm>
<textarea name="ta" wrap="soft" cols="80" rows="10">
the alerted value

should look exactly as what is entered in the textbox.
</textarea>
<input type="button" value="text()" onclick="text()")
</form>
</body>
</html>

The only problem I see is when the textarea causes words to a new line
because of line overflow; this is not the same as a newline.
Jul 23 '05 #2
Thanks. Your example work because you have entered a hard carriage
return. What I need is, when the text in the textbox automatically
wrapped because of the cols value, I would be able to retrieve the
text as what the user sees in the text box. The example below the user
did NOT do a carriage return between "long" and "string" when the
information is typed into the textbox.
------------------------
|This is a very long |
|string. |
| |
------------------------
The value I need would be "This is a very long\nstring".
Jul 23 '05 #3
"chin" <ch****@hotmail.com> wrote in message
news:f0*************************@posting.google.co m...
Thanks. Your example work because you have entered a hard carriage
return. What I need is, when the text in the textbox automatically
wrapped because of the cols value, I would be able to retrieve the
text as what the user sees in the text box. The example below the user
did NOT do a carriage return between "long" and "string" when the
information is typed into the textbox.
------------------------
|This is a very long |
|string. |
| |
------------------------
The value I need would be "This is a very long\nstring".


Good luck! Perhaps if you used a fixed spaced font such as Courier (set via
CSS) you might be able to calculate were each row breaks.
Jul 23 '05 #4
chin wrote:
Thanks. Your example work because you have entered a hard carriage
return. What I need is, when the text in the textbox automatically
wrapped because of the cols value, I would be able to retrieve the
text as what the user sees in the text box. The example below the user
did NOT do a carriage return between "long" and "string" when the
information is typed into the textbox.
------------------------
|This is a very long |
|string. |
| |
------------------------
The value I need would be "This is a very long\nstring".


Try adding wrap="physical" to your textarea. It is not supported by all
browsers, but it will put breaks in the text string where the browser
breaks the lines, you can see it in the submit string as %0D%0A.

Have fun - Fred.
Jul 23 '05 #5
>
Try adding wrap="physical" to your textarea. It is not supported by all
browsers, but it will put breaks in the text string where the browser
breaks the lines, you can see it in the submit string as %0D%0A.

Have fun - Fred.

Thanks Fred.

Unfortunately, my problem is that I need the line break without having
to submit the page to server. It seems that I do not have much choice
but to calculate the number word in the line and put the line break
myself.
Jul 23 '05 #6

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

Similar topics

1
by: Bob Kaku | last post by:
I'm trying to retrieve a text value from a MySQL database, put it into an updateable form, allow edits, and send back the edited text back into the MySQL database. I've been able to successfully...
2
by: J_axx | last post by:
Wow I was told this is a grate place for info I did not believe um but I was wrong I have 4 ASP pages on my site & a DB for each page has a form pointing at its DB, I thought this would be the...
3
by: Sunil Kulkarni | last post by:
I need to validate my TextArea as follows: 1) IT SHOULD ALLOW FOR ONLY 5 COLUMNS 2) IT SHOULD ALLOW ONLY 65 CHARACTERS PER ROW I need some kind of a JS validation for the same. I have tried...
1
by: zoltix | last post by:
Hi, How to retrieve a value in in an aspx page? Normally it is easy, drag and drops the textarea in aspx page and it is work. But in this case, I generate the html code manually () and put as...
3
by: lintolawrance | last post by:
sir, i am starting working with php.i done some programs.but now i have one problem.i do a program like to retrieve the name and email from a phpfile to another.but i can't get. this is the code...
3
by: Alfred | last post by:
I want to post text field data from these HTML TEXTAREA tags to a PostgreSQL database and have it reappear back on another page exactly as I had typed it. Over the years I have done this but only...
1
by: gudipati | last post by:
hi,i have one problem.actually we can retrieve data from access. what is my requirement is when i retrieve data from access i want to store in text areas. finely,we can store if they r textboxes...
1
by: Blackmore | last post by:
In some of my online forms, I have a number of large 'textarea' cfinput elements that I have provided to allow the user to enter large amounts of text onto a MS Access database. I have made the...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
1
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
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...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.