Last active
January 21, 2016 09:23
-
-
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
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
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