Last active
May 5, 2016 15:48
-
-
Save jebaird/3c260d08d57539a1f15a924f44321f88 to your computer and use it in GitHub Desktop.
Parse window.location.search values to input values
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
(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