?
Solved

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

Posted on 2005-03-14
8
Medium Priority
?
305 Views
Last Modified: 2013-12-24
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!
0
Comment
Question by:dstjohnjr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 7

Accepted Solution

by:
INSDivision6 earned 1000 total points
ID: 13539869
<cfset addr="123 Main St">

<cfset addr2=Replace(addr, " ", "+", "ALL")>
<cfoutput>#addr2#</cfoutput>
0
 
LVL 17

Expert Comment

by:Tacobell777
ID: 13541261
I think you are looking for urlEncodedFormat("123 Main St.")
0
 
LVL 17

Expert Comment

by:Tacobell777
ID: 13541264
You want to pass the string via the url right? Or am I assuming to much?
0
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

 

Author Comment

by:dstjohnjr
ID: 13541536
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:

SiteName
StreetAddress
City
State
Zip
Phone

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.

Thanks!
0
 
LVL 17

Expert Comment

by:Tacobell777
ID: 13541623
Can I ask why you are doing this?
0
 

Author Comment

by:dstjohnjr
ID: 13541739
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?

Thanks!
0
 
LVL 17

Expert Comment

by:Tacobell777
ID: 13542556
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.
0
 
LVL 17

Expert Comment

by:Tacobell777
ID: 13558884
ok dont listen.
0

Featured Post

Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question