Using javascript to auto-uncheck the email opt-in box on a donation form

Options

Hi all - I wanted to share something that a client asked about in case it's useful for others.

The European Union requires that any email opt-in box be unchecked by default for online donation forms that solicit gifts from EU citizens.  The USA has no such requirement.  Rather than having separate fundraising forms, one for EU and one for USA (which might be confusing to donors), the client wanted a way to configure Donations Campaign forms to auto-uncheck the email opt-in box when a constituent selected a country that was not "USA".

A colleague at Convio came up with a javascript snippet that will do just that.  This javascript can be dropped into the PageWrapper that is used for donation forms.  Here is the code in case anyone else needs a similar solution:

]x::

<script type="text/javascript">

addOnLoadHandler(function(){

var billingCountry=document.getElementById('billing_addr_country');

if(billingCountry) Utils.addEvent(billingCountry,'blur',checkCountry);

});

function checkCountry(){

if(document.getElementById('billing_addr_country').value!='United States'){

document.getElementById('donor_email_opt_inname').checked='';

}

}

</script>

::]]

Tagged:

Categories