如何在javascript中更改所选值并在代码隐藏页面中获取所选值? AutoPostBack设置为false。
答案 0 :(得分:20)
您可以这样更改:
var ddl = document.getElementById('ddl-id');
var opts = ddl.options.length;
for (var i=0; i<opts; i++){
if (ddl.options[i].value == "some-value"){
ddl.options[i].selected = true;
break;
}
}
答案 1 :(得分:13)
//setting the value of a drop down list
document.getElementById('my_drop_down').selectedIndex=2;