Click to See Complete Forum and Search --> : Making a '+' stay where it is.


Webskater
12-04-2003, 09:53 AM
I have a text box which is populated with a phone number in international format.
e.g. <input type=text id=numbox value="+44797112233">
If I concatenate a querystring using this value like so ...
location.replace('Change.asp?Num=' + numbox.value)
The '+' at the front of the phone number is removed. I have tried using escape(numbox.value) but this does not work. How can I retain the '+' in this situation?
Any help much appreciated.

ray326
12-04-2003, 11:33 AM
The '+' isn't being removed, it's being turned into a space, ' ', because '+' is a special character in a URL. Literal plus signs should be encoded as %2b in a query string like that.

Pittimann
12-04-2003, 11:38 AM
Hi!

Why not replace "+" with something quite unique, which (practically) never appears in a formfield. I like "µ" for that.

This will be in the url and your asp file just replaces all "µ's" with "+" from the get variables again.

Ooops - ray326 - hadn't seen your post. Let's use the encoded "+" = "%2b" instead of "µ" to avoid Pit specific behaviour... :)

Cheers - Pit

Webskater
12-05-2003, 04:28 AM
Thanks for your answers.