Skip to content

Instantly share code, notes, and snippets.

@JFlynnXYZ
Last active January 21, 2016 09:23
Show Gist options
  • Save JFlynnXYZ/2a8cb800082e648cafe3 to your computer and use it in GitHub Desktop.
Save JFlynnXYZ/2a8cb800082e648cafe3 to your computer and use it in GitHub Desktop.
Takes parameters form a url after a # in the form of <formID>=<value>& Source: http://htmlasks.com/pre_fill_form_field_via_url_in_html
var hashParams = window.location.hash.substr(1).split('&'); // substr(1) to remove the `#`
if (hashParams[0] != ""){
for(var i = 0; i < hashParams.length; i++){
var p = hashParams[i].split('=');
document.getElementById(p[0]).value = decodeURIComponent(p[1]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment