妖碧落

导航

js06-左右选择

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script>
			function selectone(){
				var select1 = document.getElementById("leftSelect")
				var options1 = select1.options  //获取左边所有option 列表
				
				var rightSelect = document.getElementById("rightSelect")
				for (var i = 0;i < options1.length;i++) {
					var options11 = options1[i]
					if (options11.selected) {
						rightSelect.appendChild(options11)
						
					} 
				}
			}
			function selectAll(){
				var select1 = document.getElementById("leftSelect")
				var options1 = select1.options  //获取左边所有option 列表
				
				var rightSelect = document.getElementById("rightSelect")
				for (var i = 0;i < options1.length;i++) {
					var options11 = options1[i]					 
					rightSelect.appendChild(options11)
					i--
						
					
				}
			}
		</script>
	</head>
	<body>
	
	<table border="1px solid black" width="400px">
		<tr>
			<td>分类名称</td>
			<td>
				<input type="text" value="手机数码" />
			</td>
		</tr>
		<tr>
			<td>分类描述</td>
			<td>
				<input type="text" value="这里面都是肾" />
			</td>
		</tr>
		<tr>
			<td>分类商品</td>
			<td>
				<div style="float: left;">
					已有商品<br />
					<select multiple="multiple" id="leftSelect">	
						<option>华为</option>
						<option>小米</option>
						<option>努比亚</option>
						<option>锤子</option>
					</select>
					<br />
					<a href="#" onclick="selectone()"> >> </a><br />
					<a href="#" onclick="selectAll()"> >>> </a><br />
				</div>
				<div style="float: right;">
					未有商品<br />
					<select multiple="multiple" id="rightSelect">
						<option>苹果</option>
						<option>三星</option>
						<option>诺基亚</option>
						<option>波导</option>
					</select>
					<br />
					<a href="#"> << </a><br />
					<a href="#"> <<< </a><br />
				</div>
			</td>
		</tr>
		<tr>
			<td colspan="2">
				<input type="submit" value="提交"/>
			</td>
			
		</tr>
	</table>
	</body>
</html>

  

posted on 2020-06-27 22:27  妖碧落  阅读(182)  评论(0编辑  收藏  举报