日期:2014-05-16  浏览次数:20378 次

JS 设置下拉选择框默认值
//根据下拉对象默认选中后台对应的记录
	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)!');
		}
	}

?