Tuesday, January 21, 2020

Loop through the options in a dropdown in vanilla JavaScript!

for(var i=0; i < Organization.options.length; i++) {
   if (Organization.options[i].value == scope) {
      Organization.selectedIndex = i;
   }
}

 
 

Also, Organization.options.length and Organization.length would serve the same purpose herein.

No comments:

Post a Comment