There are two listlists on the page. You need to move the elements in one ListBox to another. How can this function be implemented? The following article describes how JavaScript can achieve the element moving effect in the composite ListBox, if you are interested, study together.
First, let's talk about the differences between a combo box and a list box:
The combo box includes the list box and text box functions.
Text Box: Only data can be entered
List box: Only data can be selected
Combo box: both data input and''
Application Background: There are two lists on the page. You need to move the elements of one list box to another.
The basic idea of implementation:
(1) write the init method to initialize the two lists;
(2) Call the init method to add an onload event to the body;
(3) Write move (s1, s2) to move the options selected in s1 to s2;
(4) Write moveAll (s1, s2) to move all the options in s1 to s2.
(5) add an onclick event for the button.
The javascript code is as follows: