/    Sign up×
Community /Pin to ProfileBookmark

removing characters in string

I have a form for users to fill out. When they press SUBMIT it takes them to a contract page that takes the values submitted and uses them to pre-fill out the contract page. The problem is, along with the form values, “+” characters are inserted where blank spaces should be. For example:

5200 west century blvd, suite 800

would look like:
5200+west+century+blvd,+suite+800

How do I get rid of these plus characters and replace them with a blank space?

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@khalidali63Apr 16.2003 — Please read about escape and unescape function in javascript.

may be a google search will return enough results

Cheers

Khalid
Copy linkTweet thisAlerts:
@webgeekauthorApr 16.2003 — Not much help, as + is one of those un encoded characters. I saw how to turn %20 back into a blank space, and read this:

http://www.htmlgoodies.com/beyond/jspass.html

Try typing two words into one of the input fields of the example, you will see what I am encountering.

That article mentions my problem exactly, but only states that I will have to "write some extra code" in order to get rid of the plus marks in my output. I want that code, as I don't know how to write it.
Copy linkTweet thisAlerts:
@NedalsApr 16.2003 — Is this done using a server-side script or are you passing variables via the URL?

khalidali63's unescape will remove the '+'s but only if you are populating the contract page using javascript.
Copy linkTweet thisAlerts:
@DrDaMourApr 16.2003 — nobody really needs any help with this, the idead is that a string is an array of characters. so you need to search the string to find the index of the + character, then replace that with a space.

Since you are using a form, i would have to assume you're using something other than javascript, unless you are hacking it by using the get URL function in javascript. If that is the case, you need to look for functions on javascript strings, google it. I don't think anyone wants to just write yoru code for you
Copy linkTweet thisAlerts:
@NedalsApr 16.2003 — When sending data over the net, a few chars must be encoded. So, in your case use escape prior to sending and unescape on reciept.

address = escape(5200 west century blvd, suite 800);

Which adds the '+'

and

address = unescape([i]value (from name/value pair)[/i])
Copy linkTweet thisAlerts:
@webgeekauthorApr 16.2003 — I didn't ask anyone to write the code for me. Time is not a luxury I have right now. I was hoping someone could giev me a more direct answer or example.

[b]Moderator's note[/b]: I know I sometimes fly off the handle myself, but lets all try to be a little kinder. Thanks.
Copy linkTweet thisAlerts:
@NedalsApr 16.2003 — Dave..

You're right, of course. I was indeed getting confused with the GET method. However, for this application, since webgeek is passing data via the URL, it seemed that using the escape() and unescape() methods would be more appropiate.

Your comments would be appreciated. ?
Copy linkTweet thisAlerts:
@webgeekauthorApr 17.2003 — Thanks, Dave

Your answer was right on!
×

Success!

Help @webgeek spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...