代码示例:<mce:script type="text/javascript"><!-- var o; // 添加数据 function add(index){ var select1 = document.getElementById('select1'); var select2 = document.getElementById('select2'); if (index!=undefined){ o=select1.options[index]; select2.options.add(new Option(o.text,o.value)); select1.remove(index); }else{ for(var i=0;i<select1.options.length;){//不要在这里控制i的增长,因为有可能删除了option if(select1.options[i].selected){ o=select1.options[i]; select2.options.add(new Option(o.text,o.value)); select1.options.remove(i); i=0; }else i++; } } } // 添加所有数据 function addAll(){ var select1 = document.getElementById('select1'); var select2 = document.getElementById('select2'); var opt=select1.options; len=opt.length; try{ for(i=0;i<len;i++){ o=select1.options[i]; select2.options.add(new Option(o.text,o.value)); select1.remove(i); i--; } }catch(e){} } // 删除数据 function del(index){ var select1 = document.getElementById('select1'); var select2 = document.getElementById('select2'); if (index!=undefined){ o=select2.options[index]; select1.options.add(new Option(o.text,o.value)); select2.remove(index); }else{ for(var i=0;i<select2.options.length;){//不要在这里控制i的增长,因为有可能删除了option if(select2.options[i].selected){ o=select2.options[i]; select1.options.add(new Option(o.text,o.value)); select2.options.remove(i); i=0; }else i++; } } } // 删除所有数据 function delAll(){ var select1 = document.getElementById('select1'); var select2 = document.getElementById('select2'); var opt = select2.options; var len = opt.length; try{ for(i=0;i<len;i++){ o=select2.options[i]; select1.options.add(new Option(o.text,o.value)); select2.remove(i); i--; } }catch(e){} } // 添加数据(适用双击事件) function onAdd(){ var index = document.getElementById('select1').selectedIndex; try{ if(index != -1){ add(index); } }catch(e){} } // 删除数据(适用双击事件) function onDel(){ var index = document.getElementById('select2').selectedIndex; try{ if(index != -1){ del(index); } }catch(e){} } // --></mce:script>