Posted By

DrCord on 11/05/10


Tagged

select option


Versions (?)

Check if option is selected, if not select default


 / Published in: JavaScript
 

URL: www.CordSlatton.com

Very useful for changing the selected option in a select dropdown

  1. var foo = document.getElementById('yourSelect');
  2. if (foo)
  3. {
  4. if (foo.selectedIndex != null)
  5. {
  6. foo.selectedIndex = 0;
  7. }
  8. }

Report this snippet  

You need to login to post a comment.