双向选择,通常用于给多向配置

<div class="col-xs-6">
	<h5>匹配</h5>
	<p>选定一项或多项然后点击添加或移除(按住shift或ctrl可以多选),或在选择项上双击进行添加和移除。</p>
	<form method="post" name="myform">
		<table border="0" width="300">
			<tr>
				<td width="40%">
				   <select style="WIDTH: 100%" multiple id="morechannel" name="list1" size="12" οndblclick="moveOption(document.myform.list1,             document.myform.list2)">
				    </select>
				 </td>
				<td width="20%" align="center"><input type="button" value="添加"
					 οnclick="moveOption(document.myform.list1, document.myform.list2)"><br />
					 <br /> 
					 <input type="button" value="删除" οnclick="moveOption(document.myform.list2, document.myform.list1)">
				 </td>
				 <td width="40%">
				      <select style="WIDTH: 100%" multiple id="list2" name="list2" size="12" οndblclick="moveOption(document.myform.list2, document.myform.list1)">
				      </select>
				 </td>
			   </tr>
	          </table>
		   值:<input type="text" name="city" size="40">
	  </form>
</div>




     左右选择
	function moveOption(e1, e2) {
		try {
			for (var i = 0; i < e1.options.length; i++) {
				if (e1.options[i].selected) {
					var e = e1.options[i];
					e2.options.add(new Option(e.text, e.value));
					e1.remove(i);
					ii = i - 1
				}
			}
			document.myform.city.value = getvalue(document.myform.list2);
		} catch (e) {
		}
	}
	function getvalue(geto) {
		var allvalue = "";
		for (var i = 0; i < geto.options.length; i++) {
			allvalue += geto.options[i].value + ",";
		}
		return allvalue;
	}






	function changepos(obj, index) {
		if (index == -1) {
			if (obj.selectedIndex > 0) {
				obj.options(obj.selectedIndex).swapNode(
						obj.options(obj.selectedIndex - 1))
			}
		} else if (index == 1) {
			if (obj.selectedIndex < obj.options.length - 1) {
				obj.options(obj.selectedIndex).swapNode(
						obj.options(obj.selectedIndex + 1))
			}
		}
	}




	获取值:   var zhi = document.myform.city.value;  通过ajax 传向后台
	后台以字符串接收   String channelString = request.getParameter("channel");
			   String[] channelArray = channelString.split(",");
				for (int i = 0; i < channelArray.length; i++) {
					String string = channelArray[i];//分别获取到值
						
				}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值