function setSelectOption(objSelect, targetValue){ if(objSelect){ var options = objSelect.options; if(options){ var len = options.length; for(var i=0;i<len;i++){ if(options[i].value == targetValue){ options[i].defaultSelected = true; options[i].selected = true; return true; } } } else { alert('missing element(s)!'); } } else { alert('missing element(s)!'); } }