Skip to content

Instantly share code, notes, and snippets.

@8ctopotamus
Created December 19, 2019 16:11
Show Gist options
  • Save 8ctopotamus/dacec6187c2621dbc9056149c03b5830 to your computer and use it in GitHub Desktop.
Save 8ctopotamus/dacec6187c2621dbc9056149c03b5830 to your computer and use it in GitHub Desktop.
Populate an infusionsoft field based off of query param.
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