Results 1 to 2 of 2

Thread: Javascript Query String and Commas

  1. #1
    Join Date
    Apr 2006
    Posts
    30
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Javascript Query String and Commas

    I have this JS that pulls the parameters from a query string and places them into the callSearch variable

    [code]
    <script language="javascript">
    var qsParm = new Array();
    function qs() {
    var query = window.location.search.substring(1);
    var parms = query.split('&');
    for (var i=0; i<parms.length; i++) {
    var pos = parms[i].indexOf('=');
    if (pos > 0) {
    var key = parms[i].substring(0,pos);
    var val = parms[i].substring(pos+1);
    qsParm[key] = val;
    }
    }
    }

    qs();
    var country=qsParm['country'];
    var cityList=qsParm['cityList'];
    var airport=qsParm['airport'];

    callSearch('05664621','','Y','N','N',country,'',cityList,airport,'','#F5F5F5');
    </script>

    [code]

    The URL looks like this:

    http://somesite.com/Search_Engine.asp?cityList=PAR,BOD,CCF,CEQ,CQF,FNI,LYN,MRS,NCE,QXB,VRS&country=FRA&airport=JFK

    When city list has multiple citys with comma's the JS above does not parse the comma's into the callsearch 'cityList' parameter.

    When I limit the cityList parameter to one city like so, it works fine:

    http://somesite.com/Search_Engine.asp?cityList=PAR&country=FRA&airport=JFK

    Why is this happening? Any help would be great!

    Thanks in advance!!!

  2. #2
    Join Date
    Jul 2008
    Posts
    102
    Thanks
    36
    Thanked 6 Times in 6 Posts

    Default

    Try a different seperator then modify it back to commas if you need to. Im sure Ive seen them in URL's but maybe they are handled differently.

    Dal
    Programmers are tools used to convert Caffeine to code

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •