Created
August 3, 2020 22:14
-
-
Save salsalabs/73ab495a31dc1827bede1892e812a6d7 to your computer and use it in GitHub Desktop.
Supply/fill Country field on the Welcome Back pages. We need this because the Welcome Back page does not cache Country (known issue).
This file contains hidden or 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
<? | |
// SalsaScript to check if the supporter is logged in. If so, | |
// it deposits the script that populates/appends the Country field. | |
(function() { | |
var country = null; | |
if (Supporter == null) { return; } | |
country = Supporter.get("Country"); | |
country = (country == null) ? "US" : country; | |
?> | |
<!-- BEGIN Supply/fill country field on Welcome Back pages. --> | |
<script type="text/javascript"> | |
(function (country) { | |
document.addEventListener("DOMContentLoaded", () => { | |
var f = document.querySelector('form[name="subform"]'); | |
if (f == null) { return; } | |
var e = document.querySelector('*[name="Country"]'); | |
if (e != null) { | |
e.value = country; | |
} else { | |
e = document.createElement("input"); | |
e.type = "hidden"; | |
e.name = "Country"; | |
e.value = country; | |
f.appendChild(e); | |
} | |
}); | |
})("<?= country ?>"); | |
</script> | |
<!-- END Supply/fill country field on Welcome Back pages. --> | |
<? | |
})(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment