replacing %20

Discussion in 'Javascript' started by gkeogh@gmail.com, Jul 18, 2006.

  1. Guest

    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.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, 2006
    #1
    1. Advertising

  2. web.dev Guest

    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.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.
    web.dev, Jul 18, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. lucky
    Replies:
    11
    Views:
    2,561
    Lucky
    Nov 11, 2005
  2. Salman
    Replies:
    1
    Views:
    422
    Jonathan Bromley
    Apr 5, 2005
  3. Laszlo

    replacing

    Laszlo, Aug 26, 2003, in forum: Perl
    Replies:
    1
    Views:
    1,096
    Peter Jones
    Aug 26, 2003
  4. Ben Holness
    Replies:
    0
    Views:
    5,439
    Ben Holness
    Jan 6, 2006
  5. Rob Meade

    Replacing - and not Replacing...

    Rob Meade, Apr 5, 2005, in forum: ASP General
    Replies:
    5
    Views:
    274
    Chris Hohmann
    Apr 11, 2005
Loading...

Share This Page