日期:2014-05-18  浏览次数:20780 次

jsp dwr 中的<select value=?>修改赋值问题
我用dwr回调得到数据中的   select   List
在我的修改页面,我要给 <select   name= "department_id "> 赋值,可怎么也赋不上去:
  function   getDepartments(){
    departmentList.getDepartments(departItems);
  }
  function   departItems(items){
    DWRUtil.addOptions(document.getElementById( "department_id "),items, 'department_id ', 'department_name ')
  }
  getDepartments();
  function   getRolets(){
    roleList.getRoles(RoleItems);
  }
  function   RoleItems(roitems){
    DWRUtil.addOptions(document.getElementById( "role_id "),roitems, 'role_id ', 'role_remark ')
  }
  getRolets();

document.getElementById( "department_id ").value= " <%=userinfo.getDepartment_id()%> ";
其中: <%=userinfo.getDepartment_id()%> 是有值的
departmentList.getDepartments(departItems);也是有值的


------解决方案--------------------
getElementById( "department_id ")需要你把select加上一个id属性
id= "department_id "
如下
<select name= "department_id " id= "department_id ">
这样在用document.getElementById( "department_id ").value= " <%=userinfo.getDepartment_id()%> ";就可以赋值了