array problem

wxdqz

New Member
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=new Array();
for (var col=0;col<=7;col++){
temp[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??
 
Back
Top