I got a textarea in javascript but the problem is that when i make line breaks in it they won't display how can i do this ?
i'm getting the value and use a write function but it won't give line breaks
Thanks in advance
I got a textarea in javascript but the problem is that when i make line breaks in it they won't display how can i do this ?
i'm getting the value and use a write function but it won't give line breaks
Thanks in advance
A new line is just whitespace to the browser and won't be treated any different to a normal space (" "). To get a new line, you must insert <BR />
elements.
Another attempt to solve the problem: Type the text into the textarea and then add some JavaScript behind a button to convert the invisible characters to something readable and dump the result to a DIV
. That will tell you what your browser wants.
Problem comes from the fact that line breaks (\n\r?) are not the same as HTML < br /> tags
var text = document.forms[0].txt.value;
text = text.replace(/\n\r?/g, '<br />');
How would this work serverside? using this I get an error
var text = Request.Form("test")
text = text.replace(/\n\r?/g, '
');
Microsoft JScript runtime error '800a01b6'
Object doesn't support this property or method