搜索墙首页  编程技术  java  asp  ajax  php  c/c#/c++  数据库  oracle  mysql  db2  操作系统  windows  linux  股吧
首页 > 编程 > ajax > JavaScript
 1         
1楼  goby2008 2007-09-22

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>sendsysmessage.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
	 <script type=text/javascript language=JavaScript>
	 	function addmen(){
			var d = document.getElementById('select1');
			var s = document.getElementById('select2');
			//alert(d.options.length);
			for(var i=0;i<d.options.length;i++){
				if(d.options[i].selected){
					//alert(d.options[i].text);
					var obj = new Option(d.options[i].text,d.options[i].value);
					s.options.add(obj);
					d.remove(i);
				}
			}
		}
		function allmen(){
			var d = document.getElementById('select1');
			var s = document.getElementById('select2');
			//alert(d.options.length);
			for(var i=0;i<d.options.length;i++){
					//alert(d.options[i].text);
					var obj = new Option(d.options[i].text,d.options[i].value);
					s.options.add(obj);
					d.remove(i);
			}
		}
		function returnmen(){
			var d = document.getElementById('select1');
			var r = document.getElementById('select2');
			for(i=0;i<r.options.length;i++){
				if(true==r.options[i].selected){
					//alert(d.options[i].text);
					var obj = new Option(r.options[i].text,r.options[i].value);
					r.remove(i);
					d.options.add(obj);
				}
			}
		}
	 </script>
  </head>
  
  <body>
  <br>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  	<form>
    <tr>
      <td width="11%">&nbsp;</td>
      <td width="89%">&nbsp;</td>
    </tr>
    <tr>
      <td>接收人</td>
      <td><select name="select1" size="4" multiple>
        <option value="1">kk</option>
        <option value="2">dd</option>
        <option value="3">ee</option>
        <option value="4">tt</option>
      </select> <input name="d" type="button" id="d" value="&lt;&lt;" onClick="returnmen();">
        <input name="d" type="button" id="d" value="&gt;&gt;" onClick="addmen();">
		<input name="d" type="button" id="d" value="全部添加" onClick="allmen();">
        <select name="select2" size="4" multiple>
        </select>
      </td>
    </tr>
    <tr>
      <td>主题:</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>内容:</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
	</form>
  </table>
  </body>
</html>

关于多选列表框的值,多选添加到另一个列表框里有点问题,就是原来的值删除不了,或者选了两个,只添加了一个,不知道是什么原因呢?请指教。
2楼  yeaha 2007-09-22

试试全部添加完了再删除,不要边添加边删除
 1         
您的发言将按有关规定都会存档,您须为所发表后果负责,请您遵纪守法并注意语言文明。
标题:关于多选列表框的值,多选添加到另一个列表框里有点问题?
热门关注
标题回复点击
[源码]XiorkFlow:用JavaScript写的工作流设计器73540
推荐一个不错的免费JavaScript开发工具,比aptana轻得多~~70425
jquery和prototype框架的比较。。。62370
大胆预测下JS框架的走势106357
开心网【朋友买卖、咬人、争车位】Firefox插件118307
Mootools前景?拿来主义VS重复发明轮子102301
Mootools和Jquery之间的选择问题60270
Mootools、jQuery之说三道四64246
js操作html的table,包括添加行,添加列,删除行,删除列,合并单元格(未实现)29214
关于Gecko的eval第二参数探密51209
搜索墙@2009 www.pkwall.com all rights reserved QQ:276471788 [京ICP备09111534号]
声明:本站部分数据来源于网络,仅供参考,如有版权问题,请联系我们,我们将及时删除!转载本站请注明来源