Skip to content

Instantly share code, notes, and snippets.

@BPScott
Created May 30, 2012 18:07
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 BPScott/2838008 to your computer and use it in GitHub Desktop.
Save BPScott/2838008 to your computer and use it in GitHub Desktop.
<script>
(function() {
var searches = document.location.search.substr(1).split('&');
var searchesLength = searches.length;
var item, elements, elementsLength, ele, normalisedTagName;
while (searchesLength--) {
item = searches[searchesLength].split('=');
elements = document.getElementsByName(decodeURIComponent(item[0]));
elementsLength = elements.length;
while (elementsLength--) {
ele = elements[elementsLength];
normalisedTagName = ele.tagName.toLowerCase();
if (normalisedTagName === 'input' || normalisedTagName === 'textarea') {
ele.value = decodeURIComponent(item[1]);
}
}
}
}());
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment