Created
April 19, 2012 16:14
-
-
Save bootandy/2422043 to your computer and use it in GitHub Desktop.
Javascript widgit for selecting correct value of a HTML menu dropdown
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> | |
menu = document.getElementById('menu_element'); | |
for (i = 0; i < menu.length; i++) { | |
if (menu.options[i].value == '{{value_to_select}}') { | |
menu.selectedIndex = i; | |
break; | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment