[Javascript] linebreak in textarea

Matt Barton javascript at mattbarton.org
Mon May 24 09:20:35 CDT 2004


Hi,

Using IE6 and WinXP, it would seem that \n does the trick for me...
The following code certainly results in a line break being inserted into the
textarea....

<!-- START-->
<html>
 <body>
  <textarea id="test"></textarea>
  <script language="javascript">
   document.getElementById("test").value = "mystring\nmysting";
  </script>
 </body>
</html>
<!-- END -->

There's probably something here dreadfully obvious that I've missed...

Matt

----- Original Message ----- 
From: "Paul McGuire" <pmcguire at cguk.co.uk>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Monday, May 24, 2004 3:09 PM
Subject: Re: [Javascript] linebreak in textarea


> My JavaScript is populating a textbox.
>
> myform.textboxfield.value = 'mystring'
>
> I would like a way to auto insert linebreaks into the text box too.
>
> myform.textboxfield.value = 'mystring\n'
>
> just prints
>
> mystring\n
>
> into the text box as does
>
> myform.textboxfield.value = 'mystring' + '\n'
>
> How would I programatically put a sting into a textbox with linebreaks
> inserted?
>
> Paul
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
> --
> This email has been verified as Virus free
> Virus Protection and more available at http://www.plus.net




More information about the Javascript mailing list