sel.options[sel.options.length] = new Option(select.xtype,select.xtypeId);
下拉框回显 修改时
var sel = $("#tuijian1")[0];// 大类
$("#tuijian1").find("option:selected").text();
for ( var i = 0; i < sel.length; i++) {
if (sel[i].text == select.productRecomme) {
sel.selectedIndex = i;
}
}
清空select
var sel = document.getElementById('productType21');
sel.length = 0;
用js控制selected
第一种方法:
<form name="aaa">
<SELECT name="j_tsryj">
<OPTION value="1">满意</OPTION>
<OPTION value="2">不满意</OPTION>
<OPTION value="3">其他</OPTION>
<OPTION value="4">其他1</OPTION>
<OPTION value="5">其他2</OPTION>
<OPTION value="6">其他3</OPTION>
</SELECT>
<form>
<script>
aaa.j_tsryj.selectedIndex="4";//显示第5个option
</script>
第二种方法:
<form name="aaa">
<SELECT name="j_tsryj" id="t">
<OPTION value="1">满意</OPTION>
<OPTION value="2">不满意</OPTION>
<OPTION value="3">其他</OPTION>
<OPTION value="4">其他1</OPTION>
<OPTION value="5">其他2</OPTION>
<OPTION value="6">其他3</OPTION>
</SELECT>
<form>
<script>
document.getElementById("t").options[1].selected=true;//显示第2个
</script>
第三种方法:
<form name="bbb">
<SELECT name="j_tsryj" id="t">
<OPTION value="1">满意</OPTION>
<OPTION value="2">不满意</OPTION>
<OPTION value="3">其他</OPTION>
<OPTION value="4">其他1</OPTION>
<OPTION value="5">其他2</OPTION>
<OPTION value="6">其他3</OPTION>
</SELECT>
<form>
<script>
document.getElementById("t").value="6";//显示最后一个
</script>