Click to See Complete Forum and Search --> : array problem


glotsa
03-27-2003, 01:50 AM
I have an array (myDetail) and would like to do some filtering and put the filited records to a new array (temp)

var temp=new Array();(as global variable)
var i=0;

for (var row in myDetail) {
if (eval(str)){<-----this is the filitering rule, if match, then put the corresponding records to temp array
temp[i]=new Array();
for (var col=0;col<=7;col++){
temp[i][col]=myDetail[row][col];
}
i++;
}
}

sometimes, there are 6 six records matched, sometimes, there are 3 records matched for example. I would like to ask how can i clear the temp array every time??

I have enountered a problem that for the first time, there are 6 records match. (thus, temp array contains 6 rows). But for the second filtering, there are only two records match. The data of first two rows are updated, but the left 4 rows still contain the data for the last filtering. How can i fix this problem??or can i delete the left 4 rows??

Nedals
03-27-2003, 01:57 AM
Try..
temp[i] = ();

glotsa
03-27-2003, 02:55 AM
but it does not work~~

Scriptage
03-27-2003, 06:09 AM
To delete a variable simply:

variable_name = null;

so to redefine temp:

temp = null;
var temp = new Array();

You now have a completely blank array.

Regards