The returned string from the ajax call has two sets of data wish I split into an array with one data set in each row of the "aCombined" array.
From there I split each of the data sets into separate arrays. In this case the "aPhaseCodes" array holds the data I which to manipulate (see below)
I wish to build an array of objects from which I can dynamically create a listbox populated with the data returned in the aPhaseCodes array.
Sample data:
aCombined
0
"72755;Contract Drilling Services;1110"
1
aPhaseCodes"1099_92;1110_10;1199_30;5080_80"
0
"1099_92"
1
"1110_10"
2
"1199_30"
3
----------------------------------"5080_80"
Desired Output
oPhaseCoder
Object 1099=Object 1110=Object 1199=Object 5080=Object
1099
Object
0
Object text=92
text
"92"
value
"92"
1110
Object
0
Object text=10
text
"10"
value
"10"
Expand|Select|Wrap|Line Numbers
-
var aTemplates = new Object();
var dDept = new Array(); - dDept[dDept.length] = string2Array(aPhaseCodes[0].substring(0,4));
- for (var i = 0; i < aPhaseCodes.length; i++ )
- {
- var pCode = aPhaseCodes[i].substring(5,7);
- if (dDept == aPhaseCodes[i].substring(0,4))
- {
- dDept[dDept.length] = {value:pCode, text:pCode};
- }else{
- aTemplates[dDept] = dDept;
- dDept.length = 0;
- dDept = string2Array( aPhaseCodes[i].substring(0,4) );
- dDept[dDept.length] = {value:pCode, text:pCode};
- }
- }
- function xPC(value, text)
- {
- this.value = value
- this.text = text
- }
- function string2Array(string) {
- eval("var result = " + string);
- return result;
- }