<select id="department" onchange="" style="width:150px;"> </select>
departmentList = oBook.departmentList;
var departmentSelect = document.getElementById("department");departmentSelect.options.length=0;/**清空下拉框的值*/
if((departmentList!=null)&&(departmentList.length!=0)) {
for(var i=0; i<=departmentList.length; i++){
var op = new Option();
op.text=departmentList[i].name;
op.value=departmentList[i].id;
departmentSelect.options.add(op);
}}
来源:https://www.cnblogs.com/yony/archive/2012/07/01/2572049.html