How do I substitute all spaces with plus symbol in a text input field

Hello all,

I am looking for a way to substitute all space characters in a given text input field with the plus symbol.  For instance, the original field value of the text input might be something like "123 Main St." and I would like to substitute it as "123+Main+St.".

Thanks in advance for helping with this!
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.

<cfset addr="123 Main St">

<cfset addr2=Replace(addr, " ", "+", "ALL")>

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
I think you are looking for urlEncodedFormat("123 Main St.")
You want to pass the string via the url right? Or am I assuming to much?
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

dstjohnjrAuthor Commented:
No, this is not in the URL, it is on a form with multiple fields.  The fields that would typically have spaces to be substituted with the plus symbol are:


although the fields that most typically have the spaces to be substituted are SiteName, StreetAddress and Phone.

I am going to try the code initially recommended by INSDivision6 and will be back here with my results either way.

Can I ask why you are doing this?
dstjohnjrAuthor Commented:
Certainly.  I have a client that has hundreds of restaurants in the US and Canada.  They have a backend database application that stores all of the information about the restaurants.  In addition to the standard location fields (address, city, state, zip, etc.) there are also fields that we use for Mapquest (i.e. MQAddress, MQCity, MQState, etc.).  The Mapquest fields cannot contain any spaces - only the plus symbol (presumably because we are passing this information in the URL line - which would probably substantiate your initial question).  So, for our client, we have a data entry process whereas whenever they open a new restaurant, they first have to enter basic location information about the restaurant.  The next step is to to configure the location to be used with Mapquest.  When they enter the form to configure the location to be displayed with Mapquest, we are pre-populating the form with values from the initial address information they entered, then substituting all spaces with the plus symbol so that they really don't have to do anything further except to submit the form.  Does that make sense?

yup makes sense, if you are about to pass any data over the url you need to think about more characters than just the space, which is why cf provides urlEncodedFormat()

I would strongly suggest you use that instead, it does not convert a space to a plus, but %20 which is the html equivalent of a space.
ok dont listen.
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 Servers

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.