Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > replacing %20

Reply
Thread Tools

replacing %20

 
 
gkeogh@gmail.com
Guest
Posts: n/a
 
      07-18-2006
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

 
Reply With Quote
 
 
 
 
web.dev
Guest
Posts: n/a
 
      07-18-2006

http://www.velocityreviews.com/forums/(E-Mail Removed) 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacing String Using Regular Expression lucky ASP .Net 11 11-11-2005 07:01 AM
Guide: Replacing your North Bridge Heatsink RObErT_RaTh Reviews & How-To's 34 09-08-2005 07:22 AM
Replacing - and not Replacing... Rob Meade ASP General 5 04-11-2005 06:49 PM
Replacing groups of statements Salman VHDL 1 04-05-2005 03:42 PM
Replacing UTP with wireless, what equipment? Joel Dorfan Wireless Networking 2 10-31-2004 12:44 PM



Advertisments