stack13
03-22-2005, 10:21 PM
Hi all. After going around for a while, I cant get array.slice() working fine. Here is why:
var holder = new Array ();
holder[0] = new Array ();
holder[0]["ID"] = 1;
holder[0]["TITLE"] = "Revistas";
holder[0]["DESCRIPTION"] = "Revistas Viejas";
holder[0]["PUBLICATION_DAY"] = 1;
holder[0]["PUBLICATION_MONTH"] = 1;
holder[0]["PUBLICATION_YEAR"] = 2005;
holder[0]["EXPIRATION_DAY"] = 1;
holder[0]["EXPIRATION_MONTH"] = 5;
holder[0]["EXPIRATION_YEAR"] = 2006;
holder[1] = new Array ();
holder[1]["ID"] = 2;
holder[1]["TITLE"] = "Mis Fotos";
holder[1]["DESCRIPTION"] = "Imagenes Personales";
holder[1]["PUBLICATION_DAY"] = 22;
holder[1]["PUBLICATION_MONTH"] = 2;
holder[1]["PUBLICATION_YEAR"] = 2005;
holder[1]["EXPIRATION_DAY"] = 30;
holder[1]["EXPIRATION_MONTH"] = 10;
holder[1]["EXPIRATION_YEAR"] = 2006;
holder[2] = new Array ();
holder[2]["ID"] = 3;
holder[2]["TITLE"] = "Descargas";
holder[2]["DESCRIPTION"] = "Libros y otras yerbas";
holder[2]["PUBLICATION_DAY"] = 1;
holder[2]["PUBLICATION_MONTH"] = 1;
holder[2]["PUBLICATION_YEAR"] = 2005;
holder[2]["EXPIRATION_DAY"] = 23;
holder[2]["EXPIRATION_MONTH"] = 3;
holder[2]["EXPIRATION_YEAR"] = 2007;
function removeElement(array,e){
if(!array[e]) return false;
return array.splice(e,1);
}
removeElement(this.holder,e);
If var e is the last key of array, [2 in this case] the function works good. If lower than 2 instead, splice() removes e++. Should I use parseInt() or anything like that? I tried adding -1 but things get even worst. I guess Im using this method quite specifically, maybe an error at defining? Thanks in advance.
-mak
var holder = new Array ();
holder[0] = new Array ();
holder[0]["ID"] = 1;
holder[0]["TITLE"] = "Revistas";
holder[0]["DESCRIPTION"] = "Revistas Viejas";
holder[0]["PUBLICATION_DAY"] = 1;
holder[0]["PUBLICATION_MONTH"] = 1;
holder[0]["PUBLICATION_YEAR"] = 2005;
holder[0]["EXPIRATION_DAY"] = 1;
holder[0]["EXPIRATION_MONTH"] = 5;
holder[0]["EXPIRATION_YEAR"] = 2006;
holder[1] = new Array ();
holder[1]["ID"] = 2;
holder[1]["TITLE"] = "Mis Fotos";
holder[1]["DESCRIPTION"] = "Imagenes Personales";
holder[1]["PUBLICATION_DAY"] = 22;
holder[1]["PUBLICATION_MONTH"] = 2;
holder[1]["PUBLICATION_YEAR"] = 2005;
holder[1]["EXPIRATION_DAY"] = 30;
holder[1]["EXPIRATION_MONTH"] = 10;
holder[1]["EXPIRATION_YEAR"] = 2006;
holder[2] = new Array ();
holder[2]["ID"] = 3;
holder[2]["TITLE"] = "Descargas";
holder[2]["DESCRIPTION"] = "Libros y otras yerbas";
holder[2]["PUBLICATION_DAY"] = 1;
holder[2]["PUBLICATION_MONTH"] = 1;
holder[2]["PUBLICATION_YEAR"] = 2005;
holder[2]["EXPIRATION_DAY"] = 23;
holder[2]["EXPIRATION_MONTH"] = 3;
holder[2]["EXPIRATION_YEAR"] = 2007;
function removeElement(array,e){
if(!array[e]) return false;
return array.splice(e,1);
}
removeElement(this.holder,e);
If var e is the last key of array, [2 in this case] the function works good. If lower than 2 instead, splice() removes e++. Should I use parseInt() or anything like that? I tried adding -1 but things get even worst. I guess Im using this method quite specifically, maybe an error at defining? Thanks in advance.
-mak