Escaping plus symbol (+) in textarea

I have a form with a textarea that is outputting data from my database, when a (+) symbol is entered in the form and submitted like "C++" it gets saved in the database correctly but displays "C  " without the (+) symbols. I believe it is getting taken out of the page via javascript and have tried the code below but it doesn't work.
<script>
escape( 
	objParams[ strKey ] 
	 
	// Escape the "+" manually.
	).replace( 
		new RegExp( "\\+", "g" ), 
		"%2B" 
		) 
</script>

Open in new window

tribalboy3000Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ChetOS82Commented:
Is there any javascript running on the page that might do this?  You say it gets saved as "C++", so is the issue when you try to display the form again?
0
SRigneyCommented:
Are you checking what is being submitted with the form in your server side?
0
tribalboy3000Author Commented:
The form is actually a CFFORM on a Coldfusion page. I know that when CF is interpreted javascript is sometimes added to the source code. When the form is submitted ( C++) it is being stored in the database as (C++), when it is being passed back to the web page it is not displaying the (++) just (C  ) is showing.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

SRigneyCommented:
In that case you probably need to convert data coming out of the database into safe data before using it on the web page.
0
scrathcyboyCommented:
an HTML text area is designed only for basic text (letters and numbers) and no special characters.  Whether going into CF, or a form submit, the text area does not preserve special characters, carriage returns, line feeds, and any special formatting, including HTML.  If you want to preserver these, you use the RICH text area, which is a simple plug in to any web page -- try it, you will likely find it works fine --

www.textarearich.com/
www.dynamicdrive.com/dynamicindex16/richtexteditor/index.htm
www.tcpiq.com/tcpIQ/HTMLRichTextArea/
www.topshareware.com/HTML-Rich-Text-Area-download-1456.htm
0
tribalboy3000Author Commented:
Im using Rich Text in my CFForm, the problem I found is that the textarea is being passed thru the url and the (+) symbol is being replaced by a blank space.
0
ChetOS82Commented:
How is the textarea being populated?  You say "thru the url", but that doesn't make sense to me.

A plus symbol is not a special character to a textarea, but it is to a URL (the plus symbol is a space), I just don't understand your process of getting the value out of the database and into the textarea.
0
tribalboy3000Author Commented:
I figured it out! the form "value" was being passed thur a url and the (+) symbol when being used in the textform was not going thru. Example (C+ or C++). I had to use a replace to change out the (+) to (%2B) which is the html format for (+).
<a href="frm_InsertCurMod.cfm?COURSETITLE=#Trim(COURSETITLE)#&FORMVALUE=
#Replace(Replace(COURSE_DESCR,"++","%2B%2B"), "+", "%2B")#&ACAD_PLAN=#ACAD_PLAN#"> Edit Course Description</a>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.