By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,442 Members | 1,332 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,442 IT Pros & Developers. It's quick & easy.

replacing %20

P: n/a
I have the followng code which reads in variables in the URL and
converts them to javascript vars.

<script language="JavaScript">
if (window.location.search.length>1){
Params = window.location.search.substring(1);
Pairs = Params.split("&");
for (i=0;i<Pairs.length;i++){
theVar = Pairs[i].split("=");
eval(theVar[0] +'="'+ theVar[1]+'"');
}
}
</script>
when i do a document.write, my vars are writing out, BUT the spaces are

all displayed as
%20 (see below)
%20API/Bulk%20Manufacturing,%20Finished%20Dose
I have tried a few ideas but cant replace the "%20" with a " "
Anyone any suggestions?
Cheers
Gary

Jul 18 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

gk****@gmail.com wrote:
I have the followng code which reads in variables in the URL and
converts them to javascript vars.

<script language="JavaScript">
if (window.location.search.length>1){
Params = window.location.search.substring(1);
Pairs = Params.split("&");
for (i=0;i<Pairs.length;i++){
theVar = Pairs[i].split("=");
eval(theVar[0] +'="'+ theVar[1]+'"');
}
}
</script>
when i do a document.write, my vars are writing out, BUT the spaces are

all displayed as
%20 (see below)
%20API/Bulk%20Manufacturing,%20Finished%20Dose
I have tried a few ideas but cant replace the "%20" with a " "
Anyone any suggestions?
Cheers
Gary
Unescape your querystring with the unescape() function before you start
parsing it.

With that said, there are plenty of libraries out there which help
facilitate getting the name/value pairs from the querystring. You
should try to look them up.

Jul 18 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.