M
mattrapoport
I have a page with a div on it. The div displays a user comment. When
the user logs into this page, their current comment is pulled from a db
and displayed in the div. The user can edit the comment through a
pop-up that contains a textarea. When the user hits OK on the pop-up,
the text in the textarea is sent to a function on the main page. The
function inserts the text into the div's text node.
Please don't ask why I'm making this so complicated - there are other
things going on on the page and the pop-up that are irrelevant to my
problem.
Everything works perfectly except when the user puts carriage returns
in their comment. For some reason I can't get the carriage returns to
show up in the div. BUT! When they view the existing comment in the
div (the one pulled from the database) the carriage returns are
displayed. That initial display does not use any javascript - it's
just php so the page is initially rendered with the text in the div.
So it seems that when I programmatically put text into my div, the
carriage returns don't show. But if the page is rendered with the text
already there, the carriage returns do show.
This seems like it should be so simple, what am I doing wrong??? Do I
have to replace the carriage returns with a different character (e.g.
<br>, \n, \r, \n\r, \r\n)? Or is there a css setting for the div?
Any help would be greatly appreciated.
- Matt
the user logs into this page, their current comment is pulled from a db
and displayed in the div. The user can edit the comment through a
pop-up that contains a textarea. When the user hits OK on the pop-up,
the text in the textarea is sent to a function on the main page. The
function inserts the text into the div's text node.
Please don't ask why I'm making this so complicated - there are other
things going on on the page and the pop-up that are irrelevant to my
problem.
Everything works perfectly except when the user puts carriage returns
in their comment. For some reason I can't get the carriage returns to
show up in the div. BUT! When they view the existing comment in the
div (the one pulled from the database) the carriage returns are
displayed. That initial display does not use any javascript - it's
just php so the page is initially rendered with the text in the div.
So it seems that when I programmatically put text into my div, the
carriage returns don't show. But if the page is rendered with the text
already there, the carriage returns do show.
This seems like it should be so simple, what am I doing wrong??? Do I
have to replace the carriage returns with a different character (e.g.
<br>, \n, \r, \n\r, \r\n)? Or is there a css setting for the div?
Any help would be greatly appreciated.
- Matt