简体   繁体   中英

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

If you need to pass data from the view to a controller you need to implement 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

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 .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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