Skip to content

Instantly share code, notes, and snippets.

@jebaird
Last active May 5, 2016 15:48
Show Gist options
  • Select an option

  • Save jebaird/3c260d08d57539a1f15a924f44321f88 to your computer and use it in GitHub Desktop.

Select an option

Save jebaird/3c260d08d57539a1f15a924f44321f88 to your computer and use it in GitHub Desktop.
Parse window.location.search values to input values
(function(){
var regex = /[?&]([^=#]+)=([^&#]*)/g,
input,
match;
while( match = regex.exec( window.location.search ) ) {
input = document.querySelector('[name="'+ match[1] +'"' );
if ( input ) {
input.value = decodeURIComponent( match[2] );
}
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment