Skip to content

Instantly share code, notes, and snippets.

@salsalabs
Created August 28, 2019 14:44
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/aef01ceb70ab910878b1bac9c33dfabf to your computer and use it in GitHub Desktop.
Save salsalabs/aef01ceb70ab910878b1bac9c33dfabf to your computer and use it in GitHub Desktop.
Script to set the default value for a <select> (dropdown). The script contains a field name and an option name for a Salsa client.
<script type="javascript">
//Script to look for a specific value in a <select> (dropdown). If found
//then make it the default.
document.addEventListener(function() {
var e = document.querySelector('select[name="auswahl_spendenzweck"]');
if (e != null) {
var option = e.querySelector('option[value="Da wo es am nötigsten ist"]');
if (option != null) {
option.selected = true;
}
}
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment