"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.