Конечно, можно. Например, так:
| Код | <html> <head> <script> function moveRight() { var first = document.getElementById("first"); var second = document.getElementById("second"); if(first.selectedIndex!=-1) { second.options[second.options.length] = new Option(first.options[first.selectedIndex].text); for(var i = first.selectedIndex; i<first.options.length-1; i++) { first.options[i].text = first.options[i+1].text; } first.options.length = first.options.length-1; } } function moveLeft() { var first = document.getElementById("first"); var second = document.getElementById("second"); if(second.selectedIndex!=-1) { first.options[first.options.length] = new Option(second.options[second.selectedIndex].text); for(var i = second.selectedIndex; i<second.options.length-1; i++) { second.options[i].text = second.options[i+1].text; } second.options.length = second.options.length-1; } } </script> </head> <body> <div align="center"> <select id="first" size="7"> <option>one</option> <option>two</option> <option>three</option> </select> <select id="second" size="7"> <option>four</option> <option>five</option> <option>six</option> </select> <br> <input type="button" onClick="moveLeft()" value="<<"> <input type="button" onClick="moveRight()" value=">>"> </div> </body> </html>
|
Учти, код упрощенный. |