469,349 Members | 1,511 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,349 developers. It's quick & easy.

Creating a URL encoded value in JavaScript

I'm working on a web application which needs to submit information to the
server via a URL string. The URL can contain values retrieved from form
input fields. I'm using the escape function to preprocess values from
input fields, but I have a problem when the input field contains a '+'
(plus sign). Since the escaped value gets put into a URL, the server
doesn't see the '+', but rather a blank. Is there any other javascript
function which will automatically escape a '+' in addition to the other
characters that it already escapes?

Thanks.

--
James Howe
Jul 23 '05 #1
1 2459
On 06 Apr 2004 16:31:06 EDT, James Howe
<co************@wingspread.imap-mail.com> wrote:
I'm working on a web application which needs to submit information to
the server via a URL string. The URL can contain values retrieved from
form input fields. I'm using the escape function to preprocess values
from input fields, but I have a problem when the input field contains a
'+' (plus sign). Since the escaped value gets put into a URL, the
server doesn't see the '+', but rather a blank. Is there any other
javascript function which will automatically escape a '+' in addition
to the other characters that it already escapes?


The simplest thing to do is convert plus symbols to their hex-escaped
versions first, then use the escape() function. When you perform the
reverse, convert plus symbols to spaces, then use unescape().

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Michael | last post: by
5 posts views Thread by Vandana Rola | last post: by
26 posts views Thread by Protoman | last post: by
6 posts views Thread by Chris Fink | last post: by
1 post views Thread by wingsforwheels | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.