Created
March 26, 2019 16:47
-
-
Save salsalabs/b4e0395375489f0b4231b303276c26bd to your computer and use it in GitHub Desktop.
Script to set the default value of a Receive_Email field in a Classic form to -3. All other fields named "Receive_Email" are removed to avoid confusion.
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
<!-- BEGIN Default Receive_Email to unsubscribed. --> | |
<script type="text/javascript"> | |
document.addEventListener("DOMContentLoaded", function () { | |
// Remove hard-coded Receive_Email hidden inputs. That will leave the | |
// Receive_Email dropdown that the user can see. | |
var a = document.querySelectorAll('input[name=Receive_Email]'); | |
a.forEach(function(e) { | |
e.parentNode.removeChild(e); | |
}); | |
// Set the default value for the Receive Email dropdown. | |
var e = document.querySelector('select[name=Receive_Email]'); | |
if (e != null) { | |
e.value = -3; | |
} | |
}); | |
</script> | |
<!-- End Default Receive_Email to unsubscribed. --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment