Last active
July 17, 2020 22:12
-
-
Save spence-man/aa6acf1d7d3deb270243b5a99c17144a to your computer and use it in GitHub Desktop.
populate-infs-form.js
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
<script> | |
// ref: https://community.infusionsoft.com/t/is-there-a-way-to-pre-fill-an-order-form/10713/9 | |
function getParameterByName(name, url) { | |
if (!url) url = window.location.href; | |
name = name.replace(/[\[\]]/g, "\\$&"); | |
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), | |
results = regex.exec(url); | |
if (!results) return null; | |
if (!results[2]) return ''; | |
return decodeURIComponent(results[2].replace(/\+/g, " ")); | |
} | |
var email = getParameterByName('inf_field_Email'); | |
// -> "john@smith.com" | |
var firstName = getParameterByName('inf_field_FirstName'); | |
// -> "John" | |
var lastName = getParameterByName('inf_field_LastName'); | |
// -> "Smith" | |
var getParameterByName('inf_field_Phone1'); | |
// -> "1-777-777-7778" | |
jQuery('#firstName').val(firstName); | |
jQuery('#lastName').val(lastName); | |
// ... | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment