Connecting Tech Pros Worldwide Help | Site Map

replacing %20

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 18th, 2006, 04:15 PM
gkeogh@gmail.com
Guest
 
Posts: n/a
Default replacing %20

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


  #2  
Old July 18th, 2006, 05:15 PM
web.dev
Guest
 
Posts: n/a
Default Re: replacing %20


gkeogh@gmail.com wrote:
Quote:
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.

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.