Skip to content

Instantly share code, notes, and snippets.

@bootandy
Created April 19, 2012 16:14
Show Gist options
  • Save bootandy/2422043 to your computer and use it in GitHub Desktop.
Save bootandy/2422043 to your computer and use it in GitHub Desktop.
Javascript widgit for selecting correct value of a HTML menu dropdown
<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