Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salsalabs/b4e0395375489f0b4231b303276c26bd to your computer and use it in GitHub Desktop.
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.
<!-- 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