Answers for "javascript select option based on text"

0

javascript select option based on text

var textToFind = 'Google';

var dd = document.getElementById('MyDropDown');
for (var i = 0; i < dd.options.length; i++) {
    if (dd.options[i].text === textToFind) {
        dd.selectedIndex = i;
        break;
    }
}
Posted by: Guest on June-22-2020

Code answers related to "javascript select option based on text"

Code answers related to "Javascript"

Browse Popular Code Answers by Language