0

I am trying to accomplish the following using only HTML and Javascript.

When users fill out a my form, their form data is appended to a confirmation page like this: http://www.mysite.com/confirmation/?firstname=Hans&lastname_Schwartz&country=Germany

On that page, based on url parameters, I want to display all locations in locations.json with a country that's equal to Germany. It's either über simple or totally impossible. After hours of searching, I don't know which is true.

Even a HINT or pointing me to an existing example would be helpful. I've been at it for hours. Total n00b. Thx.

Sara
  • 1
  • Take a look at http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values . With that, you could get the value of the `country` key. From there, you could do things based on that value – Ian Apr 06 '13 at 04:07
  • Which technology you are using like `PHP`,`.NET`,`JAVA`, etc? You can use `jquery.ajax` for this. – Rohan Kumar Apr 06 '13 at 04:23

1 Answers1

0

got this script from here

(function($) {
    $.QueryString = (function(a) {
    if (a == "") return {};
    var b = {};
    for (var i = 0; i < a.length; ++i)
    {
        var p=a[i].split('=');
        if (p.length != 2) continue;
        b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
    }
    return b;
    })(window.location.search.substr(1).split('&'))
})(jQuery);

var firstname = $.QueryString["firstname"];
var lastname = $.QueryString["lastname"];
var country = $.QueryString["country"];

using the the value country you can easily display all locations

Community
  • 1
  • 1
Nisanth Sojan
  • 1,099
  • 8
  • 21