如何实现 A 栏的选中的内容 通过按钮移动到 B 栏 http://hi.baidu.com/quandafei/blog/item/816f9d2bf7eaa1fbe7cd4001.html你要的是上面的这个意思? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是这样吗?<body>A:<select id="a" size="5" multiple="multiple" style="width:200px"> <option value="1">option_1</option> <option value="2">option_2</option> <option value="3">option_3</option> <option value="4">option_4</option> <option value="5">option_5</option></select> B:<select id="b" size="5" multiple="multiple" style="width:200px"></select><br /><input type="button" onclick="reto('a','b')" value=" >>B " style="margin-left:20px" /><input type="button" onclick="reto('b','a')" value=" A<< " style="margin-left:200px" /><script> function reto(source, destination){ var s = document.getElementById(source), d = document.getElementById(destination); ins_ops(d, get_ops(s)); } function get_ops(sel){ // 得到所选 var ops = []; for(var i=0; i<sel.options.length; i++) if(sel.options[i].selected){ ops.push(sel.options[i]); } return ops; } function ins_ops(sel, ops){ // 移动所选 for(var i=0; i<ops.length; i++){ sel.appendChild(ops[i]); } }</script></body> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><TITLE> 下拉框日常操作 </TITLE><META NAME="Generator" CONTENT="EditPlus"><META NAME="Author" CONTENT="liangchao"><SCRIPT LANGUAGE="JavaScript"><!-- function $(sId){return document.getElementById(sId)}window.onload = function(){ $('leftSel').size = $('leftSel').options.length; $('rightSel').size = $('leftSel').options.length;}function changeOrd(sign){ if(sign == 'right'){ var Index = $('leftSel').options.selectedIndex; if(Index >= 0){ var selText = $('leftSel').options[$('leftSel').selectedIndex].text; $('leftSel').options.remove(Index); $('rightSel').options.add(new Option(selText,selText)) }else{ alert('无选中选项'); } }else if(sign == 'left'){ var Index = $('rightSel').options.selectedIndex; if(Index >= 0){ var selText = $('rightSel').options[$('rightSel').selectedIndex].text; $('rightSel').options.remove(Index); $('leftSel').options.add(new Option(selText,selText)) }else{ alert('无选中选项'); } }else if(sign == 'up'){ var Index = $('leftSel').options.selectedIndex; if(Index > 0){ var temp; temp = $('leftSel').options[$('leftSel').selectedIndex].text; $('leftSel').options[$('leftSel').selectedIndex].text = $('leftSel').options[$('leftSel').selectedIndex-1].text; $('leftSel').options[$('leftSel').selectedIndex-1].text = temp; $('leftSel').options[$('leftSel').selectedIndex-1].selected = true; }else{ alert('已至最顶端!'); } }else if(sign == 'down'){ var Index = $('leftSel').options.selectedIndex; if(Index < $('leftSel').options.length-1){ var temp; temp = $('leftSel').options[$('leftSel').selectedIndex].text; $('leftSel').options[$('leftSel').selectedIndex].text = $('leftSel').options[$('leftSel').selectedIndex+1].text; $('leftSel').options[$('leftSel').selectedIndex+1].text = temp; $('leftSel').options[$('leftSel').selectedIndex+1].selected = true; }else{ alert('已至最底端!'); } } }//--></SCRIPT></HEAD><BODY><SELECT NAME="left" id='leftSel' style="overflow:hidden;width:50px"><OPTION VALUE="中国">中国</option><OPTION VALUE="英国">英国</option><OPTION VALUE="法国">法国</option><OPTION VALUE="日本">日本</option><OPTION VALUE="俄国">俄国</option><OPTION VALUE="德国">德国</option></SELECT> <INPUT TYPE="button" value='右移' onclick="changeOrd('right')"> <INPUT TYPE="button" value='上移' onclick="changeOrd('up')"> <INPUT TYPE="button" value='下移' onclick="changeOrd('down')"><INPUT TYPE="button" value='左移' onclick="changeOrd('left')"> <SELECT NAME="rigth" id='rightSel' style="overflow:hidden;width:50px"></SELECT></BODY></HTML> <TABLE id=YourId><TR BGCOLOR="#FFFFFF"> <td width="75">a</td> <td width=246>b</td></tr><TR BGCOLOR="#FFFFFF"> <td width="75">aa</td> <td width=246>bb</td></tr><TR BGCOLOR="#FFFFFF"> <td width="75">aaa</td> <td width=246>bbb</td></tr></TABLE> <FORM NAME="Form1"> <INPUT TYPE="Button" NAME="Button1" VALUE="单击"> <script for="Button1" EVENT="onClick" LANGUAGE="VBScript"> dim t t=YourId.rows(0).cells(0).innerText YourId.rows(0).cells(0).innerText=YourId.rows(0).cells(1).innerText YourId.rows(0).cells(1).innerText=t t=YourId.rows(1).cells(0).innerText YourId.rows(1).cells(0).innerText=YourId.rows(1).cells(1).innerText YourId.rows(1).cells(1).innerText=t t=YourId.rows(2).cells(0).innerText YourId.rows(2).cells(0).innerText=YourId.rows(2).cells(1).innerText YourId.rows(2).cells(1).innerText=t </script></FORM> 高人帮助研究一下这个代码 类似sina博客的消息提示框特效 网页切割 全选复选框选择问题:当下面的复选框全部被选中时,全选复选框自动被选中 javascript 的radio验证问题 JavaScript可取本页的URL地址吗? 生日放分! 用了iframe怎么调iframe里的页面的方法? 计数器问题 tr中的文本不让选中 奇怪为什么会多输出一个undefined?请各位朋友指点一下,谢谢了 发一个格式化函数,大家给提些意见
<body>
A:<select id="a" size="5" multiple="multiple" style="width:200px">
<option value="1">option_1</option>
<option value="2">option_2</option>
<option value="3">option_3</option>
<option value="4">option_4</option>
<option value="5">option_5</option>
</select>
B:<select id="b" size="5" multiple="multiple" style="width:200px"></select>
<br />
<input type="button" onclick="reto('a','b')" value=" >>B " style="margin-left:20px" />
<input type="button" onclick="reto('b','a')" value=" A<< " style="margin-left:200px" />
<script>
function reto(source, destination){
var s = document.getElementById(source), d = document.getElementById(destination);
ins_ops(d, get_ops(s));
} function get_ops(sel){ // 得到所选
var ops = [];
for(var i=0; i<sel.options.length; i++)
if(sel.options[i].selected){
ops.push(sel.options[i]);
}
return ops;
} function ins_ops(sel, ops){ // 移动所选
for(var i=0; i<ops.length; i++){
sel.appendChild(ops[i]);
}
}
</script>
</body>
<HTML>
<HEAD>
<TITLE> 下拉框日常操作 </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="liangchao">
<SCRIPT LANGUAGE="JavaScript">
<!--
function $(sId){return document.getElementById(sId)}
window.onload = function(){
$('leftSel').size = $('leftSel').options.length;
$('rightSel').size = $('leftSel').options.length;
}function changeOrd(sign){
if(sign == 'right'){
var Index = $('leftSel').options.selectedIndex;
if(Index >= 0){
var selText = $('leftSel').options[$('leftSel').selectedIndex].text;
$('leftSel').options.remove(Index);
$('rightSel').options.add(new Option(selText,selText))
}else{
alert('无选中选项');
}
}else if(sign == 'left'){
var Index = $('rightSel').options.selectedIndex;
if(Index >= 0){
var selText = $('rightSel').options[$('rightSel').selectedIndex].text;
$('rightSel').options.remove(Index);
$('leftSel').options.add(new Option(selText,selText))
}else{
alert('无选中选项');
}
}else if(sign == 'up'){
var Index = $('leftSel').options.selectedIndex;
if(Index > 0){
var temp;
temp = $('leftSel').options[$('leftSel').selectedIndex].text;
$('leftSel').options[$('leftSel').selectedIndex].text = $('leftSel').options[$('leftSel').selectedIndex-1].text;
$('leftSel').options[$('leftSel').selectedIndex-1].text = temp;
$('leftSel').options[$('leftSel').selectedIndex-1].selected = true;
}else{
alert('已至最顶端!');
}
}else if(sign == 'down'){
var Index = $('leftSel').options.selectedIndex;
if(Index < $('leftSel').options.length-1){
var temp;
temp = $('leftSel').options[$('leftSel').selectedIndex].text;
$('leftSel').options[$('leftSel').selectedIndex].text = $('leftSel').options[$('leftSel').selectedIndex+1].text;
$('leftSel').options[$('leftSel').selectedIndex+1].text = temp;
$('leftSel').options[$('leftSel').selectedIndex+1].selected = true;
}else{
alert('已至最底端!');
}
}
}
//-->
</SCRIPT></HEAD><BODY>
<SELECT NAME="left" id='leftSel' style="overflow:hidden;width:50px">
<OPTION VALUE="中国">中国</option>
<OPTION VALUE="英国">英国</option>
<OPTION VALUE="法国">法国</option>
<OPTION VALUE="日本">日本</option>
<OPTION VALUE="俄国">俄国</option>
<OPTION VALUE="德国">德国</option>
</SELECT>
<INPUT TYPE="button" value='右移' onclick="changeOrd('right')">
<INPUT TYPE="button" value='上移' onclick="changeOrd('up')">
<INPUT TYPE="button" value='下移' onclick="changeOrd('down')"><INPUT TYPE="button" value='左移' onclick="changeOrd('left')"> <SELECT NAME="rigth" id='rightSel' style="overflow:hidden;width:50px"></SELECT>
</BODY>
</HTML>
<TR BGCOLOR="#FFFFFF">
<td width="75">a</td>
<td width=246>b</td>
</tr>
<TR BGCOLOR="#FFFFFF">
<td width="75">aa</td>
<td width=246>bb</td>
</tr>
<TR BGCOLOR="#FFFFFF">
<td width="75">aaa</td>
<td width=246>bbb</td>
</tr>
</TABLE> <FORM NAME="Form1">
<INPUT TYPE="Button" NAME="Button1" VALUE="单击">
<script for="Button1" EVENT="onClick" LANGUAGE="VBScript">
dim t
t=YourId.rows(0).cells(0).innerText
YourId.rows(0).cells(0).innerText=YourId.rows(0).cells(1).innerText
YourId.rows(0).cells(1).innerText=t
t=YourId.rows(1).cells(0).innerText
YourId.rows(1).cells(0).innerText=YourId.rows(1).cells(1).innerText
YourId.rows(1).cells(1).innerText=t
t=YourId.rows(2).cells(0).innerText
YourId.rows(2).cells(0).innerText=YourId.rows(2).cells(1).innerText
YourId.rows(2).cells(1).innerText=t
</script>
</FORM>