Created
August 28, 2019 14:44
-
-
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.
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
<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