I have a text area in HTML
where the user can enter text, but when the form is submitted, and its passed to a php
script which echo
's it, there aren't any newlines. Knowing that HTML
does that, I tried doing a preg_replace()
before echoing it...
echo preg_replace("/\n/", "<br />", $_GET["text"]);
but still everything is on one line.
So my best guess is that HTML
textareas use a different newline character... can anybody shed some light on the subject?
EDIT
Ok, so I've figured out the problem: The Javascript is stripping the newlines. view code here
EDIT 2
Ok, so thanks to Jason for solving this problem. I needed to do:
escape(document.getElementById('text'));
Instead of just:
document.getElementById('text');
and the newlines are preserved, problem solved!