Skip to content

Instantly share code, notes, and snippets.

@DZuz14
Last active June 30, 2017 13:40
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 DZuz14/de7584165e21845d6d8b48871adce9c1 to your computer and use it in GitHub Desktop.
Save DZuz14/de7584165e21845d6d8b48871adce9c1 to your computer and use it in GitHub Desktop.
Query string value extraction
function urlExtractor(url) {
url = decodeURIComponent(url);
var charIndex = url.indexOf('=');
if(charIndex < 0) {
return;
}
var sliced = url.slice(charIndex).substring(1).replace(/_/g, ' ');
var inputField = document.getElementById('lead_source');
inputField.value = sliced;
return;
}
urlExtractor(window.location.href);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment