怎么用jsp给select中options赋值

怎么用jsp给select中options赋值
在JS中先给select定义个id,通过var select=document.getElementById();取这个select,如果你要改变是的选中option的value的话就用select.option[select.selectedIndex].value给它赋值,如果你要改的是option显示的值的话~就只能用innerHTML了~select.option[select.selectedIndex].innerHTML
jsp给select中options赋值,参考方法如下:
var t = document.getElementById("select1");
var selectValue=t.options[t.selectedIndex].value;//获取select的值
var t1 = document.getElementById("select2");
for(i=0;i if(selectValue==t.options[i].value){
t1.options[i].selected=true
}
}
你可以在select中直接给他赋值啊!

← 上一篇: 下一篇: →