473,386 Members | 1,943 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Objects and Arrays

Claus Mygind
571 512MB
This is driving me buggy. but I cannot get a returned string from an ajax call to associative array (hash table)

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
"1099_92;1110_10;1199_30;5080_80"
aPhaseCodes
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
  1. var aTemplates = new Object();
            var dDept = new Array();
  2.         dDept[dDept.length] = string2Array(aPhaseCodes[0].substring(0,4));
  3.  
  4.         for (var i = 0; i < aPhaseCodes.length; i++ )
  5.         {
  6.  
  7.             var pCode = aPhaseCodes[i].substring(5,7);
  8.  
  9.             if (dDept == aPhaseCodes[i].substring(0,4))
  10.             {
  11.                 dDept[dDept.length] = {value:pCode, text:pCode};
  12.             }else{
  13.                 aTemplates[dDept] = dDept;
  14.                 dDept.length = 0;
  15.                 dDept = string2Array( aPhaseCodes[i].substring(0,4) );
  16.                 dDept[dDept.length] = {value:pCode, text:pCode};
  17.             }
  18.         }
  19. function xPC(value, text)
  20. {
  21.     this.value = value
  22.     this.text = text
  23. }
  24. function string2Array(string) {
  25.     eval("var result = " + string);
  26.     return result;
  27. }
  28.  
  29.  
Nov 24 '08 #1
1 1099
Claus Mygind
571 512MB
@Claus Mygind
I solved this problem.
Nov 24 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: John Smith | last post by:
Can someone point me to an example of how to implement and access the kind of object shown below? Most of the examples if found are an object that contains one other object. I need to create an...
3
by: ABC | last post by:
I am not a javascript guru or anything so I was wondering if someone could tell me what the code below is doing. Is it creating a multidimensional array? Would it be better to create an object? ...
8
by: Thomas Mlynarczyk | last post by:
Hi! If A is an object, then "B = A;" will just assign a reference. Isn't there a simple way to create an actual copy of A and assign that to B? Greetings, Thomas
2
by: don | last post by:
My question is, do C++ array of objects hold the objects or just the pointers to the objects..... I know Java arrays only hold pointers to objects, but I seem to remember that C++ arrays hold the...
5
by: Gent | last post by:
I have two questions which are very similar: Is it possible to return an object in C++. Below is part of my code for reference however I am more concerned about the concept. It seems like the...
21
by: Matteo Settenvini | last post by:
Ok, I'm quite a newbie, so this question may appear silly. I'm using g++ 3.3.x. I had been taught that an array isn't a lot different from a pointer (in fact you can use the pointer arithmetics to...
5
by: Gomaw Beoyr | last post by:
Hello Is there any explanation why Microsoft chose to implement arrays as objects allocated on the heap instead of structs allocated on the stack? For "mathematical stuff", one normally...
25
by: Jack | last post by:
Hi, Is there a general solution for the following problem: I have an array of instances of class B. Class B is publicly derived from class A. Then I have a class named Buffer that generally...
1
by: Mike Kent | last post by:
The APL 2007 conference, sponsored by ACM SIGAPL, has as its principal theme "Arrays and Objects" and, appropriately, is co-located with OOPSLA 2007, in Montreal this October. APL 2007 starts...
12
by: gnewsgroup | last post by:
I've read the msdn doc about IEnumerable. It seems to me that IEnumerable objects are essentially wrapped-up arrays. It simply gives us the foreach convenience. Is this correct?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.