高校计算机

3773考试网计算机等级考试高校计算机正文

应用实例JSP+JavaScript打造级连菜单

来源:fjzsksw.com 2009-11-3 16:09:28

temp=<%=temp%>;
  function ChangeLocation(id){
  document.combo_box.city.length=0; //初始化第2级菜单的长度,下标从0开始
  var i = 0;
  document.combo_box.city.options[0]=new Option("-------","");
  for(i=0;i<temp;i++){
  if(arr[i][1]==id){//如果相等,证明在第2级里面有输入第1级组织的子集,arr[总数目][部门]
  document.combo_box.city.options[document.combo_box.city.length] = new Option(arr[i][0], arr[i][0]);
  }
  }
  }
  </script>
  <form name="combo_box">
  <table border="0" cellspacing="0" cellpadding="0" height="210" width="59">
  <tr height="24">
  <td bgcolor="#336699" class="buttons" align=center><font color=#ffffff>部门选择</font></td>
  <td bgcolor="#336699" class="buttons" align=center><font color=#ffffff>人名选择</font></td>
  <td bgcolor="#336699" class="buttons" align=center nowrap><font color=#ffffff>添加/移除</font></td>
  <td bgcolor="#336699" class="buttons" align=center><font color=#ffffff>最终人</font></td>
  </tr>
  <tr>
  <td>
  <select multiple id=prov name="prov"
  onchange="ChangeLocation(combo_box.prov.options[combo_box.prov.selectedIndex].text);"
  style="width:150;height:200" class="bgc">
  <option value="0">请选择部门 ---></option>
  <%
  String sqld="SELECT * FROM tdept";
  stmt=conn.createStatement();
  rs=stmt.executeQuery(sqld);
  while(rs.next())
  {
  %>
  <option name="<%=rs.getString("fno")%>"><%=rs.getString("fname")%></option>
  <%
  }
  %>
  </select>
  </td>
  <td>
  <select multiple id=city style="width:150;height:200" class="bgc">
  </select>
  </td>
  <td nowrap align="center" class="bgc">
  <input type="button" onClick="move(this.form.list2,this.form.city)" value="<<" class="buttons">
  <input type="button" onClick="move(this.form.city,this.form.list2)" value=">>" class="buttons">
  </td>
  <td>
  <select multiple size="10" name="list2" style="width:150;height:200" class="bgc">
  </select>
  </td>
  </tr>

上一页  [1] [2] [3] 下一页

触屏版 电脑版
3773考试网 琼ICP备12003406号-1