0

Could someone help me to get the querystring in an array on page reload Here is an example of the querystring https://local.abc.com/?country=us&state=California&city=Los%20Angeles&city=abc%20Plan&city=xyz

I need to get the list of city from the querystring to further perform some action on the city list. Any input is appreciated.

Ms1
  • 45
  • 5
  • 1
    Does this answer your question? [Get querystring from URL using jQuery](https://stackoverflow.com/questions/4656843/get-querystring-from-url-using-jquery) – kapsiR Nov 30 '21 at 20:34

1 Answers1

0

getting one code row from Get querystring from URL using jQuery here is result:

var cities = [];
var a = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (i in a) {
    var n = a[i].split("=");
    if (n[0].toUpperCase() == "CITY") {
        cities.push(decodeURIComponent(n[1]));
    }
}
console.log(cities);

cities is the array containing all cities from URI

diavolic
  • 722
  • 1
  • 4
  • 5