MktoForms2 :: Multi-checkbox to Thank You
by sanford
HTML
<script src="//app-sj01.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_116"></form>
<script>MktoForms2.loadForm("//app-sj01.marketo.com", "410-XOR-673", 116,
function(form)
{
form.onSuccess( function(form,thankYouBaseURI)
{
var allChecked = [];
for ( var labels = this.formElem[0].querySelectorAll('input[type=checkbox] ~ label')
, i = 0
, imax = labels.length; i < imax ; i++ )
{
var lbl = labels[i].innerText; // label text
var cbx = document.getElementById( labels[i].htmlFor ) // label's associated input
if ( cbx.checked ) {
allChecked.push( lbl ); // add label of checked checkbox to array
}
}
// append checked to the #hash of the Thank You page and redirect
var thankYouFullURI = document.createElement('A');
thankYouFullURI.href = thankYouBaseURI;
thankYouFullURI.hash = allChecked;
document.location = thankYouFullURI;
return false;
});
});
</script>
CSS
INPUT:focus {
outline: none;
}