简体   繁体   English

Javascript多重选择框

[英]Javascript multiple select box

I am trying to create multiple select boxes. 我正在尝试创建多个选择框。 So I list in one box which I want to move to two other boxes. 因此,我在一个框中列出了我想移至其他两个框中的内容。 When I move item from one list to other , item gets moved from that list and I want to keep it in that list and clone into other list..When I use clone function , its not getting passed from view to controller 当我将项目从一个列表移动到另一个列表时,项目将从该列表移动,我想将其保留在该列表中并克隆到另一个列表中。当我使用克隆功能时,它不会从视图传递到控制器

 return !$('#orim option:selected').clone().appendTo('#reqnew');

So when I use above code its just dodnt pass any value to the backend in grails 因此,当我使用上面的代码时,它的确不会将任何值传递给grails的后端

If you need to pass data from the view to a controller you need to implement ajax. 如果需要将数据从视图传递到控制器,则需要实现ajax。 So for example in the list1 you need to add some relevant information maybe store it in a html5 data attribute, and then using jquery ajax function or axios among many others solutions pass does data to a controller action and from there perform your back-end logic 因此,例如,在list1中,您需要添加一些相关信息,也许将其存储在html5数据属性中,然后使用jquery ajax函数或axios等许多解决方案将数据传递到控制器操作,并从那里执行后端逻辑

So By getting value and append it to new div and original list helped the problem ..But I am still not sure why appending cloned object didn't work . 因此,通过获取价值并将其附加到新的div和原始列表中,可以解决此问题。但是我仍然不确定为什么添加克隆的对象行不通。

var options =  $('#ori').find(':selected').clone();
$('#ori').find(':selected').appendTo('#reqm');
options.prependTo('#ori');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM