468,107 Members | 1,321 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Passing an '&' as part of the parameter's value in a query string

I have a situation where I will collect text from a textbox and pass that
text as one of the parameters in another pages query string. the problem is
that if the user types in a '&' as part of the text message, the page being
called thinks the '&' is parsing out another parameter. Using JavaScript,
what should I do to pass the entire message in the query string?

Thanks.

--
mo*******@newsgroup.nospam
Sep 12 '07 #1
4 1416
moondaddy wrote:
I have a situation where I will collect text from a textbox and pass that
text as one of the parameters in another pages query string. the problem is
that if the user types in a '&' as part of the text message, the page being
called thinks the '&' is parsing out another parameter. Using JavaScript,
what should I do to pass the entire message in the query string?

Thanks.
Use the encodeURIComponent function to encode the value that you put in
the URL.

You should do this for any values that you put in an URL that might
contain characters that needs encoding.

--
Göran Andersson
_____
http://www.guffa.com
Sep 12 '07 #2
On Sep 12, 9:19 am, "moondaddy" <moonda...@newsgroup.nospamwrote:
I have a situation where I will collect text from a textbox and pass that
text as one of the parameters in another pages query string. the problem is
that if the user types in a '&' as part of the text message, the page being
called thinks the '&' is parsing out another parameter. Using JavaScript,
what should I do to pass the entire message in the query string?
& = %26

Sep 12 '07 #3
Alexey Smirnov wrote:
On Sep 12, 9:19 am, "moondaddy" <moonda...@newsgroup.nospamwrote:
>I have a situation where I will collect text from a textbox and pass that
text as one of the parameters in another pages query string. the problem is
that if the user types in a '&' as part of the text message, the page being
called thinks the '&' is parsing out another parameter. Using JavaScript,
what should I do to pass the entire message in the query string?

& = %26
That is correct, but that only solves the problem with that specific
character. There are several other characters that are not valid in a
value in a query string, like spaces for example.

--
Göran Andersson
_____
http://www.guffa.com
Sep 12 '07 #4
Thanks!

encodeURIComponent worked perfect.
"Göran Andersson" <gu***@guffa.comwrote in message
news:uF*************@TK2MSFTNGP06.phx.gbl...
moondaddy wrote:
>I have a situation where I will collect text from a textbox and pass that
text as one of the parameters in another pages query string. the problem
is that if the user types in a '&' as part of the text message, the page
being called thinks the '&' is parsing out another parameter. Using
JavaScript, what should I do to pass the entire message in the query
string?

Thanks.

Use the encodeURIComponent function to encode the value that you put in
the URL.

You should do this for any values that you put in an URL that might
contain characters that needs encoding.

--
Göran Andersson
_____
http://www.guffa.com

Sep 12 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by ~~~ .NET Ed ~~~ | last post: by
3 posts views Thread by Peter Bailey | last post: by
9 posts views Thread by Ray | last post: by
5 posts views Thread by jab3 | last post: by
7 posts views Thread by Oleg Konovalov | last post: by
1 post views Thread by Deecrypt | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.