In my role I enter data entered in an array and in a box for user viewing. But if he wants to remove this information, he selects it and is withdrawn through the function! But if he reports the same information again, it reports error already existing!
Ex:
variaveis na function
w_Cont_Qtde = 1;
w_Qtde_Peri = $arr_w_param[10]; --> $arr_w_param[10] é a quantidade informada em uma tela anterior (ex: 5 / 10 / ...)
v_patr = new Array (w_Qtde_Peri);
Inserts the data
function move(Origem, Destino)
{
var w_valor = Origem.value;
if (w_Cont_Qtde <= w_Qtde_Peri)
{
if ((v_patr.indexOf(w_valor) == -1) && (w_valor != ""))
{
var opt = document.createElement("option");
opt.text = w_valor ;
opt.value = w_valor ;
Destino.options.add(opt);
v_patr[w_Cont_Qtde]= w_valor;
w_Cont_Qtde = w_Cont_Qtde +1;
return true;
}
else
{
alert("Patrimônio OU Serial já existe OU não é válido!");
return true;
}
}
alert("Quantidade informada ja Incluida !!!");
return true;
}
Remove data (only deleting from the box)
function tira(Destino)
{
var i;
for(i = 0; i < Destino.options.length; i++)
{
if (Destino.options[i].selected && Destino.options[i].value != "")
{
w_valor=Destino.options[i].value;
w_Cont_Qtde = w_Cont_Qtde - 1;
Destino.remove(Destino.selectedIndex);
}
}
}
My problem is: "Delete the selected data from the array too, since it already deletes the box."