Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title></title>
  5.  
  6. </head>
  7. <body>
  8. <table>
  9. <tr>
  10. <td rowspan="2">
  11. <select multiple="" id="salida" style="width: 150px; height: 150px">
  12. <option value="Volvo">Volvo</option>
  13. <option value="Mazda">Mazda</option>
  14. <option value="Chevrolet">Chevrolet</option>
  15. <option value="KIA">KIA</option>
  16. <option value="Ford">Ford</option>
  17. </select>
  18. </td>
  19. <td>
  20. <input type="button" id="derecha" value=">>>" style="width: 100px; height: 40px" onclick="Seleccionar(1);"/>
  21. </td>
  22. <td rowspan="2">
  23. <select multiple="" id="llegada" style="width: 150px; height: 150px">
  24.  
  25. </select>
  26. </td>
  27. <tr><td>
  28. <input type="button" id="izquierda" value="<<<" style="width: 100px; height: 40px" onclick="Seleccionar(2);"/>
  29. </td></tr>
  30.  
  31. </tr>
  32. </body>
  33. <script type="text/javascript">
  34. function Seleccionar(num) {
  35. console.log('Este boton se encarga de pasar el listado de la izquierda a la derecha')
  36.  
  37. if (num == 1) {
  38. var salida = document.getElementById('salida');
  39. var llegada = document.getElementById('llegada');
  40.  
  41. var posicion = llegada.options.length;
  42. var selecionado = salida.selectedIndex;
  43.  
  44. if(selecionado != -1)
  45. {
  46. var mover = salida.options[selecionado];
  47. llegada.options[posicion] = new Option(mover.text, mover.value);
  48. salida.options[selecionado] = null;
  49. }
  50. }else if (num == 2){
  51. var salida= document.getElementById('llegada');
  52. var llegada= document.getElementById('salida');
  53.  
  54. var posicion = llegada.options.length;
  55. var selecionado = salida.selectedIndex;
  56.  
  57. if(selecionado != -1)
  58. {
  59. var mover = salida.options[selecionado];
  60. llegada.options[posicion] = new Option(mover.text, mover.value);
  61. salida.options[selecionado] = null;
  62. }
  63. }
  64.  
  65. }
  66. </script>
  67. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement