Setting the value of a select form element using JavaScript

Word Finder

[Tip: enter a letter and press 'Select matching Word' button ]

The code

function set_matching_word(selectObj, txtObj) {
  var letter = txtObj.value;
 
  for(var i = 0; i < selectObj.length; i++) {

    if(selectObj.options[i].value == letter)
      selectObj.selectedIndex = i;
 
  }

}

Download the code here: javascript-form-value-select.zip

Back to article: set a form field using Javascript