Skip to content

Instantly share code, notes, and snippets.

@kylefdoherty
Created March 18, 2019 00:29
Show Gist options
  • Save kylefdoherty/9d932e78a29aea5d3ceab6cd4f8aedcb to your computer and use it in GitHub Desktop.
Save kylefdoherty/9d932e78a29aea5d3ceab6cd4f8aedcb to your computer and use it in GitHub Desktop.
var setHiddenInputValues = function (formId, urlParams) {
var inputs = document.getElementById(formId).elements
inputsArr = Array.apply(null, inputs)
hiddenInputs = inputsArr.filter(function(i) {
return i.type === 'hidden';
})
// set value of inputs to the url params passed in
hiddenInputs.forEach(function(i) {
key = i.name;
val = urlParams[key];
if (val) {
i.value = val;
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment