javascript - Display JSON data in HTML page based on URL parameters -
this question has answer here:
- how can query string values in javascript? 73 answers
i trying accomplish following using html , javascript.
when users fill out form, form data appended confirmation page this: http://www.mysite.com/confirmation/?firstname=hans&lastname_schwartz&country=germany
on page, based on url parameters, want display locations in locations.json country that's equal germany. it's either über simple or totally impossible. after hours of searching, don't know true.
even hint or pointing me existing example helpful. i've been @ hours. total n00b. thx.
got script here
(function($) { $.querystring = (function(a) { if (a == "") return {}; var b = {}; (var = 0; < 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 value country can display locations
Comments
Post a Comment