PDA

View Full Version : Replace Ascii Characters from text area.


SYMBIO
12-20-2002, 09:42 AM
Hi, I have a preview function in my web app. People enter text into a text AREA and press preview. this launches a window which shows what the article would look like, if live.

I have added some code which stores CARRIAGE RETURNS as "<BR />. instead of the user typing <BR />. it works in ASP, to STORE the story into the database, but to preview in JavaScript, i cant seem to capture the ASCII carriage return, and replace them with <BR />.

jalarie
12-20-2002, 08:44 PM
Try this:

&nbsp;Value=Value.replace(/\n/g,'<br \/>');

or this:

&nbsp;Value=Value.replace(/\r/g,'<br \/>');

joeframbach
12-20-2002, 08:50 PM
or this:

val=val.split("\r\n").join("<BR>")

SYMBIO
12-23-2002, 09:24 AM
cheers!!!