Gracias de antemano.
Aca esta el codigo
Código PHP:
<script type="text/javascript">
function pasar() {
obj=document.getElementById('sel1');
if (obj.selectedIndex==-1) return;
for (i=0; opt=obj.options[i]; i++)
if (opt.selected) {
valor=opt.value;
txt=obj.options[i].text;
obj.options[i]=null;
obj2=document.getElementById('sel2');
if (obj2.options[0].value=='-')
obj2.options[0]=null;
opc = new Option(txt,valor);
eval(obj2.options[obj2.options.length]=opc);
}
}
var cadena= new Array();
function armaSql(){
obj=document.getElementById('select');
for (i=0; opt=obj.options[i]; i++){
cadena[i] = opt.value + "," + obj.options[i].text;
}
var cadenaSql =cadena.join(',');
}
</script>
Código HTML:
<form id="form1" method="post" action="pruebaLista3.php"> <p> <label for="sel1">Origen:</label> <select name="sel" size="5" multiple="multiple" id="sel1"> <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 name="select[]" size="5" id="sel2"> <option value='-'>-</option> </select> </p> <p> <input type="button" value="Pasar" onclick="pasar()" /> <input type="submit" name="button" id="button" value="Enviar" onclick="armaSql()"/> <input name="cadenaSql" type="hidden"> </p> </form>
Código PHP:
<?php
if (isset($_POST['button'])){
$cadena = $_POST["cadenaSql"];
$tokenCadena= explode(',',$cadena);
for ($i=0;$i<count($cadena);$i++){
$consulta = $cadena[$i].$cadena[$i+1];
echo $consulta;
}
}
?>