Return to Snippet

Revision: 46728
at May 24, 2011 03:08 by sanbor


Initial Code
resetDropdown : function() {
    var dropdown = this.getElementById('languageSelector');
    for (var i = dropdown.length-1; i >= 0; i--) {
      if (dropdown.options[i].defaultSelected) {
        dropdown.selectedIndex = i;
        break;
      }
    }
  }

Initial URL


Initial Description
Sets the current element of a dropdown to the default option.
<select>
   <option>Afrikaans</option>
   <option>English</option>
</select>

Initial Title
Reset select to the default value

Initial Tags
js

Initial Language
JavaScript