Link to home
Start Free TrialLog in
Avatar of m_r_productions
m_r_productions

asked on

Replace a carriage return in TEXTAREA with chr(13)?

I am making a Web site for a group within my local church, and the leader is fairly computer-ILliterate.  But, he wants a page where he can add content by filling out a form.  I have created a form for him where he can type some text in a TEXTAREA form, PLUS add formatting by clicking button images next to the box.  He clicks a button (for example, the "B" Icon for Bold/UnBold), and the corresponding mark-up is added to the end of the textbox so he can keep typing.  Here's my problem:

When he presses "Return" on his keyboard to make a carriage return, it appears in the text box, but does not transform to whitespace after it is filled out.  In other words, his words before and after the carriage return are stuck together - right next to each other.  Is there a way in ASP or JavaScript to detect the "Enter" key and insert a <br> tag there instead?  Or at least, when he submits it, have a code that replaces all carriage returns with <BR> tags?  Please reply m_r_productions@hotmail.com
ASKER CERTIFIED SOLUTION
Avatar of zombeen
zombeen

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gladxml
gladxml

m_r_productions,

>>>>
Or at least, when he submits it, have a code that replaces all carriage returns with <BR> tags?
>>>>

You can use the replace function...

tmptextarea = Replace(request.form("textarea"), "<br>", "vbcrlf")

Below is related link regarding replace method...

http://www.devguru.com/Technologies/vbscript/quickref/replace.html

HTH...

HAppy programming...
Avatar of m_r_productions

ASKER

Hey zombeen you hit the nail right on the head.  Good answer, I tried it and it worked very well.  Thank you for the quick response, too.

gladxml had a valid answer, too, except I wasn't replacing the <br> tag with chr(13).  But the answer in itself is still very useful information.  Thanks for responding, gladxml
m_r_productions,

Glad to be of help...

Reagrds,
gladxml