Created
October 10, 2019 17:55
-
-
Save adampatterson/4119a85ed087c6fa4489e5304d5a7922 to your computer and use it in GitHub Desktop.
Insert query param into form field.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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