HTML代码:
<td>
<select id="as_occt" name="as_occt">
<option selected="selected" value="">智能模糊搜索</option>
<option value="content">仅搜索内容</option>
<option value="docName">仅搜索标题</option>
</select>
</td>
JS脚本:
function _Select(o,v){
for(var i=0; i<o.options.length; i++)
if(o.options[i].value == v){
o.options[i].selected=true;
break;
}
}
function setDefaultValue(){
var as_occt = '<%=docSearchParam.getAs_occt() %>'; //从后台返回的值
var selobj = document.getElementById("as_occt"); //注意这里要用Id而不能用Name
_Select(selobj,as_occt);}
标签:初始化,selobj,occt,JS,JSP,Select,var,搜索,select
From: https://blog.51cto.com/u_2544485/7396508