您现在的位置是:网站首页> 编程资料编程资料

jsp中两个框中内容互换可以添加也可以移除_JSP编程_

2023-05-25 227人已围观

简介 jsp中两个框中内容互换可以添加也可以移除_JSP编程_

在项目中需要实现如下的效果内容。如图:

具体实现的源码如下:

两个框的页面源码:

 已选角色:

备选角色:

实现的js代码:

 function moveOptions(oSource, oTarget) { while (oSource.selectedIndex > -1) { var opt = oSource.options[oSource.selectedIndex]; oSource.removeChild(opt); var mark = true; for(var i = 0; i < oTarget.options.length; i++){ if(opt.value == oTarget.options[i].value){ mark = false; } } if(mark){ var newOpt = document.createElement("OPTION"); oTarget.appendChild(newOpt); newOpt.value = opt.value; newOpt.text = opt.text; newOpt.selected = true; } } } 

-六神源码网