Created
December 19, 2019 16:11
-
-
Save 8ctopotamus/dacec6187c2621dbc9056149c03b5830 to your computer and use it in GitHub Desktop.
Populate an infusionsoft field based off of query param.
This file contains hidden or 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
const inputToFill = document.getElementById('390') | |
const presentation = getQueryVariable('presentation') | |
function unSlugify(slug) { | |
var title = slug.split('-').join(' '); | |
var firstLetterCapital = title.charAt(0).toUpperCase(); | |
var theRest = title.substring(1); | |
return firstLetterCapital + theRest; | |
} | |
function getQueryVariable(variable) { | |
var query = window.location.search.substring(1); | |
var vars = query.split("&"); | |
for (var i=0;i<vars.length;i++) { | |
var pair = vars[i].split("="); | |
if(pair[0] == variable){return pair[1];} | |
} | |
return(false); | |
} | |
if (presentation) { | |
inputToFill.value = unSlugify(presentation) | |
inputToFill.readOnly = true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment