Hola
Mas sencillo, por el maestro
Javier_B. Solo necesitaba una pequeña modificación
Código javascript
:
Ver original<style type="text/css">
select {width:80px}
</style>
<script type="text/javascript">
<!--
function pasar1() {
obj=document.getElementById('sel1');
if (obj.selectedIndex==-1) return;
for (i=0; opt=obj.options[i]; i++)
if (opt.selected) {
valor=opt.value; // almacenar value
txt=obj.options[i].text; // almacenar el texto
obj.options[i]=null; // borrar el item si está seleccionado
obj2=document.getElementById('sel2');
opc = new Option(txt,valor);
eval(obj2.options[obj2.options.length]=opc);
}
}
function pasar2() {
obj=document.getElementById('sel2');
if (obj.selectedIndex==-1) return;
for (i=0; opt=obj.options[i]; i++)
if (opt.selected) {
valor=opt.value; // almacenar value
txt=obj.options[i].text; // almacenar el texto
obj.options[i]=null; // borrar el item si está seleccionado
obj2=document.getElementById('sel1');
opc = new Option(txt,valor);
eval(obj2.options[obj2.options.length]=opc);
}
}
-->
</script>
</head>
<body>
<p>
<label for="sel1">Origen:</label>
<select id="sel1" size="5" multiple="multiple">
<option value="1">Uno</option>
<option value="2">Dos</option>
<option value="3">Tres</option>
<option value="4">Cuatro</option>
<option value="5">Cinco</option>
</select>
<label for="sel2">Destino:</label>
<select id="sel2" size="5">
</select></p>
<input type="button" value="Pasar >>" onclick="pasar1()" />
<input type="button" value="<< Pasar" onclick="pasar2()" />
Suerte