Last active
August 17, 2018 20:03
-
-
Save salsalabs/1e44ac77a1a90df654e8 to your computer and use it in GitHub Desktop.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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