Skip to content

Instantly share code, notes, and snippets.

@adampatterson
Created October 10, 2019 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adampatterson/4119a85ed087c6fa4489e5304d5a7922 to your computer and use it in GitHub Desktop.
Save adampatterson/4119a85ed087c6fa4489e5304d5a7922 to your computer and use it in GitHub Desktop.
Insert query param into form field.
// https://www.website.com/?service_code=secretcode
$.urlParam = function (name) {
var results = new RegExp('[\?&]' + name + '=([^&#]*)')
.exec(window.location.search);
return (results !== null) ? results[1] || 0 : false;
}
// Gravity form field ID
$('#input_48_7').val($.urlParam('service_code'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment