Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TextArea property (javascript)

Status
Not open for further replies.

Sa1aam

Programmer
Joined
Feb 6, 2009
Messages
5
Hello

Does anyone know how to force a linebreak in a textarea form element.

I am able to display URL's in the textarea, but it comes out as one long text. I have tried using the wrap function as well but it doesn't break up the URL's so they appear one by one under each other.

Is there a way I can manipulate it so it can display the URL's one by one underneath each other???/

thank youu
 
You can use '\n' to force a line break, e.g.:

Code:
textObj.value = 'line1\nline2\nline3';

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Javascript using document.write - separate each line with a "\n"
Code:
<script>
document.write ("<textarea cols='25' rows='5'>this is some text[b]\n[/b]this is some more text[b]\n[/b]this is even more text</textarea>");
</script>

Pure HTML, just place each on it's own line
Code:
<textarea cols="25" rows="5">
this is some text
this is some more text
this is even more text
</textarea>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top