把第二个的VALUE和TEXXT设置成第一个的<html>
<head>
<title>无标题</title>
<head>
<body><select id=select1>
<option value = 1>select1</option>
</select>
<input type=button onclick="select2.options[select2.selectedIndex].text= select1.options[select1.selectedIndex].text;select2.options[select2.selectedIndex].value= select1.options[select1.selectedIndex].value;alert(document.all[0].outerHTML)" value = setselect2>
<select id=select2>
<option value = 1>selcet2</option>
</select>
</body>
</html>
<head>
<title>无标题</title>
<head>
<body><select id=select1>
<option value = 1>select1</option>
</select>
<input type=button onclick="select2.options[select2.selectedIndex].text= select1.options[select1.selectedIndex].text;select2.options[select2.selectedIndex].value= select1.options[select1.selectedIndex].value;alert(document.all[0].outerHTML)" value = setselect2>
<select id=select2>
<option value = 1>selcet2</option>
</select>
</body>
</html>
解决方案 »
- 在线等! jquery全选但排除某一项
- 在IE6中是不是不能禁止JavaScript呀?
- innerHTML与form表单
- 如何让一Span点击出现相应的菜单.再次点击消失相应的菜单?
- 怎么才能定义类似“Number.MAX_VALUE”的成员常量?
- 关于获取qq号码
- 请 net_lover(孟子E章) 进来一下。
- 在Javascript中如何删除select类型中的所有元素
- 大家给我看一看,其它的一切都好,就是跳转页面时无反映,jump(topage)错在哪里?
- jquery 判断 $(document).on("ready", function () {}) 执行完成
- 快本命年了,发一棵经典的树祝大家新年快乐。
- JS中我要用变量来代替DOCUMENT.ALL.DIVID中的DIVID,可以吗?怎么写呢?
<table>
<tr>
<td>
<select id='s1'>
<option>s11
<option>s12
<option>s13
</select>
</td>
<td>
<input type=button value='--->' onclick="move('right')">
<br>
<input type=button value='<---' onclick="move('left')">
</td>
<td>
<select id='s2'>
<option>s21
<option>s22
<option>s23
</select>
</td>
</tr>
</body>
<script>
function move(flag)
{
if(flag=='right') //右移
{
var s1=document.getElementById('s1');
var item=s1.options[s1.selectedIndex];
s1.removeChild(item);
document.getElementById('s2').options[document.getElementById('s2').options.length]=new Option(item.text,item.value);
}
else //左移
{
var s2=document.getElementById('s2');
var item=s2.options[s2.selectedIndex];
s2.removeChild(item);
document.getElementById('s1').options[document.getElementById('s1').options.length]=new Option(item.text,item.value);
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Page Selection</title>
<style>
td{white-space:nowrap};
body{margin-left:0;margin-right:0;margin-top=0;margin-bottom=0};
</style>
</head><body bgcolor=eeeeee><table>
<tr >
<td>
<select name=SrcSelect size=6 style="font-size:11pt;width=200;height=160px" multiple >
<option value="1">test1</option>
<option value="2">test2</option>
<option value="3">test3</option>
<option value="4">test4</option>
<option value="5">test5</option>
<option value="6">test6</option>
</select>
</td>
<td align="center">
<input align="left" type=button value="→" onclick="moveLeftOrRight(document.all.SrcSelect,document.all.ObjSelect)" ><br><br>
<input align="left" type=button value="←" onclick="moveLeftOrRight(document.all.ObjSelect,document.all.SrcSelect)" >
</td>
<td>
<select name=ObjSelect size=6 style="font-size:11pt;width=200;height=160px" multiple >
<option value="11">test11</option>
<option value="12">test12</option>
<option value="13">test13</option>
<option value="14">test14</option>
<option value="15">test15</option>
<option value="16">test16</option>
</select>
</td>
<td>
<input type=button value="↑" onclick="moveUp()" ><br><br>
<input type=button value="↓" onclick="moveDown()" >
</td>
</tr>
</table>
</body>
<script language=javascript>
function moveUp()
{
var theObj=document.all.ObjSelect;
for(var i=1;i<theObj.length;i++)
{
if( theObj.options[i].selected && !theObj.options[i-1].selected )
{
theObj.options[i].swapNode(theObj.options[i-1]);
}
}
}
function moveDown()
{
var theObj=document.all.ObjSelect;
for(var i=theObj.length-2;i>-1;i--)
{
if( theObj.options[i].selected && !theObj.options[i+1].selected )
{
theObj.options[i].swapNode(theObj.options[i+1]);
}
}
}
function moveLeftOrRight(fromObj,toObj)
{
var lengthOfToObj=toObj.length;
for(var i=fromObj.length-1;i>-1;i--)
{
if(fromObj.options[i].selected)
{
toObj.add(new Option(fromObj.options[i].text,fromObj.options[i].value),lengthOfToObj);
toObj.options[lengthOfToObj].selected=true;
fromObj.options[i].removeNode(true);
}
}
}
</script>