<script>function getOpt(select1,select2){
for (bCnt=0;bCnt<select1.length;bCnt++){
if (select1.options[bCnt].selected){
newOpt=new Option(select1.options[bCnt].text,select1.options[bCnt].value,false,false);
select2.options[select2.length]=newOpt;
remOpt(select1);/* Fix: to remove from select1 */
}
}
}
function remOpt(select2){
for (bCnt=0;bCnt<select2.length;bCnt++){
if (select2.options[bCnt].selected)
select2.options[bCnt]=null;
}
}
</script>
<form name="formname" method="post" action="">
<select name="mainip" size="5" id="mainip" class="ip" ondblclick="getOpt(document.formname.mainip,document.formname.extraip)" multiple="multiple" >
<option value="1">192.168.210.120</option>
<option value="2">192.168.210.120</option>
</select>
<select name="extraip" size="5" id="select" class="ip" ondblclick="getOpt(document.formname.extraip,document.formname.mainip)" multiple="multiple" >
<option value="1">192.168.210.120</option>
<option value="2">192.168.210.120</option>
</select></form>
Chạy tốt trên IE và FF.
Nguồn : http://thegioiweb.vn/Story/vn/laptrinhweb/laptrinhWeb_JavaScript/2009/5/7881.html
Tin mới hơn:
- Trình đơn định hướng xổ dọc
- Javacrip tạo Lịch Và Đồng Hồ
- Một số lệnh làm việc với files và thư mục trong Java
- Bộ sưu tập 200+ đoạn mã Javascript
- Sắp xếp lại các options trong drop list
Tin cũ hơn:
- Thiết kế trang Web có tăng cường tính năng Java
- Tổng quan về javascript
- Javacript với thẻ radio, checkbox
- Khai báo thẻ select dạng combo box
- Javacript với thẻ checkbox cùng tên