Foros del Web » Programando para Internet » Javascript »

controlar seleccion drag and drop sea solo uno

Estas en el tema de controlar seleccion drag and drop sea solo uno en el foro de Javascript en Foros del Web. Hola muy buenas, tengo una funcion en javascript que me realiza la accion de drag and drop entre dos cajas. La primera esta rellena con ...
  #1 (permalink)  
Antiguo 28/09/2011, 03:21
 
Fecha de Ingreso: abril-2009
Mensajes: 64
Antigüedad: 15 años
Puntos: 0
controlar seleccion drag and drop sea solo uno

Hola muy buenas, tengo una funcion en javascript que me realiza la accion de drag and drop entre dos cajas.
La primera esta rellena con un array y la segunda la vamos rellenando con este primer array.
Lo que necesito es que tan solo se pueda pasar un elemento del primer array al segundo, para que asi tan solo tengamos un elemento en la segunda caja del drag and drop. esta es la funcion:

function moveElement(side, controlOrig, controlDest) {

var temp1 = new Array();
var temp2 = new Array();
var tempa = new Array();
var tempb = new Array();
var current1 = 0;
var current2 = 0;
var y=0;
var attribute;
//controlOrig+="[]";
//controlDest+="[]";
//assign what select attribute treat as attribute1 and attribute2
if (side == "right")
{
attribute1 = document.getElementById(controlOrig); // document.form.estadoexpediente;
attribute2 = document.getElementById(controlDest); // document.form.estadoexpedienteseleccionado;
if(attribute2.lenght >1){
alert('unooooo');
}
}
else
{
attribute1 = document.getElementById(controlDest); // document.form.estadoexpedienteseleccionado;
attribute2 = document.getElementById(controlOrig); // document.form.estadoexpediente;

}

//fill an array with old values
for (var i = 0; i < attribute2.length; i++)
{
y=current1++
temp1[y] = attribute2.options[i].value;
tempa[y] = attribute2.options[i].text;
}

//assign new values to arrays
for (var i = 0; i < attribute1.length; i++)
{
if ( attribute1.options[i].selected )
{
y=current1++
temp1[y] = attribute1.options[i].value;
tempa[y] = attribute1.options[i].text;
}
else
{
y=current2++
temp2[y] = attribute1.options[i].value;
tempb[y] = attribute1.options[i].text;
}
}

//generating new options
for (var i = 0; i < temp1.length; i++)
{
attribute2.options[i] = new Option();
attribute2.options[i].value = temp1[i];
attribute2.options[i].text = tempa[i];
}

//generating new options
LimpiarOptions(attribute1,attribute1);

if (temp2.length>0)
{
for (var i = 0; i < temp2.length; i++)
{
attribute1.options[i] = new Option();
attribute1.options[i].value = temp2[i];
attribute1.options[i].text = tempb[i];
}
}




Muchas gracias por su ayuda, vengo de php y aun no manejo javascript demasiado bien
}

Etiquetas: drag, drop
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:20.