Claus Mygind
2008-11-24 19:42:22 UTC
I don't know how to get myself out of this jam. This is a little
javascript, in this case not too different than dBase I suspect.
Basically I create an object load it with properties that each have values.
I then store the information of the object I just created into an array of
objects (which really is just an associtive array).
Now here is where the problem comes in. I want to cycle around and reuse
the original object. So I clear it out. And when I do that the values in
the array are also cleared out. Here is my code if someone could give a
suggestion.
var dDept = new Object();
var vDept = aPhaseCodes[0].substring(0,4);
var pOptions = new Array();
for (var i = 0; i < aPhaseCodes.length; i++ )
{
var pCode = aPhaseCodes[i].substring(5,7);
if (vDept == aPhaseCodes[i].substring(0,4))
{
pOptions[pOptions.length] = {value:pCode,text:pCode};
}else{
dDept[vDept] = pOptions;
///problem occurs here
pOptions.length = 0;
/*
after this step the information I just stored in the line above is also
wiped out.
*/
vDept = aPhaseCodes[i].substring(0,4);
pOptions[pOptions.length] = {value:pCode,text:pCode};
}
}
dDept[vDept] = pOptions;
javascript, in this case not too different than dBase I suspect.
Basically I create an object load it with properties that each have values.
I then store the information of the object I just created into an array of
objects (which really is just an associtive array).
Now here is where the problem comes in. I want to cycle around and reuse
the original object. So I clear it out. And when I do that the values in
the array are also cleared out. Here is my code if someone could give a
suggestion.
var dDept = new Object();
var vDept = aPhaseCodes[0].substring(0,4);
var pOptions = new Array();
for (var i = 0; i < aPhaseCodes.length; i++ )
{
var pCode = aPhaseCodes[i].substring(5,7);
if (vDept == aPhaseCodes[i].substring(0,4))
{
pOptions[pOptions.length] = {value:pCode,text:pCode};
}else{
dDept[vDept] = pOptions;
///problem occurs here
pOptions.length = 0;
/*
after this step the information I just stored in the line above is also
wiped out.
*/
vDept = aPhaseCodes[i].substring(0,4);
pOptions[pOptions.length] = {value:pCode,text:pCode};
}
}
dDept[vDept] = pOptions;