Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to set a default country code in a donation page. See https://salsasupport.zendesk.com/entries/23475564-Set-a-default-country-for-a-donation-page.
<!-- BEGIN script to change the default country code and save a selected state value. -->
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function () {
var state = document.querySelector("select[name=State]");
var savedState = (state !== null) ? state.value : null;
var country = document.querySelector("select[name=Country]");
if (country != null) {
if (country.value == "") {
country.value = "US";
}
country.addEventListener("change", function() {
if (state != null && savedState != null) {
state.value = savedState;
}
});
}
});
</script>
<!-- END script to change the default country code and save a selected state value. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.