Ver Mensaje Individual
  #12 (permalink)  
Antiguo 01/02/2005, 11:57
Avatar de AlZuwaga
AlZuwaga
Colaborador
 
Fecha de Ingreso: febrero-2001
Ubicación: 34.517 S, 58.500 O
Mensajes: 14.550
Antigüedad: 23 años, 3 meses
Puntos: 535
Bueno, siguiendo la idea de Myakire, me puse a buscar algún ejemplo de javascript que haga algo similar y encontré éste http://javascript.internet.com/forms/menu-swapper.html que desactivando la funcionalidad para reordenar funcionaría, al menos para mis necesidades (recordar que no son tantos registros)

Acá dejo el código modificado y el agregado de ASP al final para demostrar los resultados:


Código:
<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
sortitems = 0;  // Automatically sort items within lists? (1 or 0)

function move(fbox,tbox) {
for(var i=0; i<fbox.options.length; i++) {
if(fbox.options[i].selected && fbox.options[i].value != "") {
var no = new Option();
no.value = fbox.options[i].value;
no.text = fbox.options[i].text;
tbox.options[tbox.options.length] = no;
fbox.options[i].value = "";
fbox.options[i].text = "";
   }
}
BumpUp(fbox);
if (sortitems) SortD(tbox);
}
function BumpUp(box)  {
for(var i=0; i<box.options.length; i++) {
if(box.options[i].value == "")  {
for(var j=i; j<box.options.length-1; j++)  {
box.options[j].value = box.options[j+1].value;
box.options[j].text = box.options[j+1].text;
}
var ln = i;
break;
   }
}
if(ln < box.options.length)  {
box.options.length -= 1;
BumpUp(box);
   }
}

function SortD(box)  {
var temp_opts = new Array();
var temp = new Object();
for(var i=0; i<box.options.length; i++)  {
temp_opts[i] = box.options[i];
}
for(var x=0; x<temp_opts.length-1; x++)  {
for(var y=(x+1); y<temp_opts.length; y++)  {
if(temp_opts[x].text > temp_opts[y].text)  {
temp = temp_opts[x].text;
temp_opts[x].text = temp_opts[y].text;
temp_opts[y].text = temp;
temp = temp_opts[x].value;
temp_opts[x].value = temp_opts[y].value;
temp_opts[y].value = temp;
      }
   }
}
for(var i=0; i<box.options.length; i++)  {
box.options[i].value = temp_opts[i].value;
box.options[i].text = temp_opts[i].text;
   }
}
// End -->
</script>

<center>
<form ACTION="" METHOD="POST">
<table border="0">
<tr>
<td><select multiple size="5" name="list1">
<option value="ID1">Uno</option>
<option value="ID2">Dos</option>
<option value="ID3">Tres</option>
</select></td>
<td>
<input type="button" value="   >>   " onclick="move(this.form.list1,this.form.list2)" name="B1"><br>
<input type="button" value="   <<   " onclick="move(this.form.list2,this.form.list1)" name="B2">
</td>
<td><select multiple size="5" name="list2">
</select></td>
</tr>
</table>
<p>
  <input type="submit" name="Submit" value="Submit">
</p>
</form>
</center>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<%
If request.form <> "" Then
	arr_list2 = Split(Request.Form("list2"), ", ")
		For i = 0 To UBound(arr_list2)
			SQL = "UPDATE tabla SET orden = " & i + 1 & " WHERE IDRegistro = '" & arr_list2(i) & "'"
			Response.Write SQL & "<br>"
		Next
End if
%>

Sólo aclarar que, luego de pasarlos de la primer lista hacia la segunda, hay que seleccionar manualmente todos los elementos para que el request.form los tome (lógico, así funcionan los selects multiples )

Bueno, se puede pulir y se pueden buscar otras alternativas si ésta no te convence demaciado, pero en vista que mis registros no son tantos y no implicaría demaiado trabajo para el usuario, creo que a mi me sirve
__________________
...___...

Última edición por AlZuwaga; 01/02/2005 a las 12:02