你好,欢迎来到电脑编程技巧与维护杂志社! 杂志社简介广告服务读者反馈编程社区  
合订本订阅
 
 
您的位置:技术专栏 / Linux开发
jsp+javascript打造级连菜单(2)
 
<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>
    <tr class="bgc">
    <td colspan="4" align="center"><input type="button" name="button1" class="buttons" value="选好了!" onclick="rv();"></td>
  </tr>
</table>
</form>

<script language="JavaScript">
//人名移动
function move(fbox, tbox) {
var arrFbox = new Array();
var arrTbox = new Array();
var arrLookup = new Array();
var i;
for (i = 0; i < tbox.options.length; i++) {
arrLookup[tbox.options[i].text] = tbox.options[i].value;
arrTbox[i] = tbox.options[i].text;
}
var fLength = 0;
var tLength = arrTbox.length;
for(i = 0; i < fbox.options.length; i++) {
arrLookup[fbox.options[i].text] = fbox.options[i].value;
if (fbox.options[i].selected && fbox.options[i].value != "") {
arrTbox[tLength] = fbox.options[i].text;
tLength++;
}
else {
arrFbox[fLength] = fbox.options[i].text;
fLength++;
   }
}
arrFbox.sort();
arrTbox.sort();
fbox.length = 0;
tbox.length = 0;
var c;
for(c = 0; c < arrFbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrFbox[c]];
no.text = arrFbox[c];
fbox[c] = no;
}
for(c = 0; c < arrTbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrTbox[c]];
no.text = arrTbox[c];
tbox[c] = no;
   }
}

</script>
</body>

(编辑:aniston)

  推荐精品文章

·2024年12月目录 
·2024年11月目录 
·2024年10月目录 
·2024年9月目录 
·2024年8月目录 
·2024年7月目录 
·2024年6月目录 
·2024年5月目录 
·2024年4月目录 
·2024年3月目录 
·2024年2月目录 
·2024年1月目录
·2023年12月目录
·2023年11月目录

  联系方式
TEL:010-82561037
Fax: 010-82561614
QQ: 100164630
Mail:gaojian@comprg.com.cn

  友情链接
 
Copyright 2001-2010, www.comprg.com.cn, All Rights Reserved
京ICP备14022230号-1,电话/传真:010-82561037 82561614 ,Mail:gaojian@comprg.com.cn
地址:北京市海淀区远大路20号宝蓝大厦E座704,邮编:100089