Posted By

sanbor on 05/24/11


Tagged

js select


Versions (?)

Reset select to the default value


 / Published in: JavaScript
 

Sets the current element of a dropdown to the default option. Afrikaans English

  1. resetDropdown : function() {
  2. var dropdown = this.getElementById('languageSelector');
  3. for (var i = dropdown.length-1; i >= 0; i--) {
  4. if (dropdown.options[i].defaultSelected) {
  5. dropdown.selectedIndex = i;
  6. break;
  7. }
  8. }
  9. }

Report this snippet  

You need to login to post a comment.