There are times you will need to grab url parameters, then update some of your form components accordingly. In my case, it was a search form that passes search terms using GET.
I largely got the javascript function from here, but I added a few lines to decode/unescape values.
Here it is.
function getUrlParameter(sParam) { var sPageURL = window.location.search.substring(1); var sURLVariables = sPageURL.split('&'); for (var i = 0; i < sURLVariables.length; i++) { var sParameterName = sURLVariables[i].split('='); if (sParameterName[0] == sParam) { var val = sParameterName[1]; //console.log("before: " + val) val = decodeURIComponent(val); val = val.replace(/+/g, " "); //console.log("after: " + val) return val; } } }; $(function() { // pre-set our search control components based on the URL params $("#search_text").val(getUrlParameter("search_text")); // more fields... });