html左边选中项写到右边框,从左边框选中到右边框中

1.有左右两个框,中间4个按钮

2.两个框的内容可以互相添加到并移除

1.[代码][JavaScript]代码

左右互移

input {

width: 100px;

height: 25px;

}

function move(opertion) {

var leftselect = window.document.getElementById("leftsel");

var rightselect = window.document.getElementById("rightsel");

if (opertion == "addall>>") {

while (leftselect.options.length > 0) {

var delElem = leftselect.removeChild(leftselect.options[0]);

rightselect.appendChild(delElem);

}

} else if (opertion == "<

while (rightselect.options.length > 0) {

var delElem = rightselect.removeChild(rightselect.options[0]);

leftselect.appendChild(delElem);

}

} else if (opertion == "add>") {

while (leftselect.selectedIndex != -1) {

var delElem = leftselect

.removeChild(leftselect.options[leftselect.selectedIndex]);

rightselect.appendChild(delElem);

}

} else{

while (rightselect.selectedIndex != -1) {

var delElem = rightselect

.removeChild(rightselect.options[rightselect.selectedIndex]);

leftselect.appendChild(delElem);

}

}

}

style="height: 300px; width: 150px;" id="leftsel">

河南

河北

陕西

山西

style="height: 300px; width: 150px;" id="rightsel">

value="addall>>">

value="

value="<

2.[图片] QQ截图20140807212715.png

07212640_B8Az.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值