James Larson
In God We Trust...
On Friday, September 14, 2012 4:40:26 PM UTC-4, FreeXenon wrote:
OK, I am getting my ass kicked by this problem. I am storing class instantiated objects into an associative array and one of two things is happening after adding the objects to the associative arrayonly the last object added is available, orall of the associated indices have the same value as the last object added.I have verified that the data that is coming in from the XML file and being pushed into into the object just prior to adding it to the associative array and it is fine, but after adding it to the associative array (declared using new Object() )... it is all messed up.Here is an example of the code I am working with:Associative Arrayvar arrObjList = new Object();arrObjList = ProcessObjectList(); // see function declaration belowAdding the Class Objects to the Associative Array from aboveProcessObjectList = function (inXML){var arrObjectList = new Object();var objClass = new clsNewClass(); // see class declaration belownodes = inXML.getElementsByTagName('thing'); for (ctr=0; ctr < nodes.length; ctr++){
// ***JAL seName is misspelled. should be setName according to declaration provided below.
--objClass.seName ( nodes[ctr].getAttributeNode('name').nodeValue ); objClass.setValue1 ( nodes[ctr].getAttributeNode('value1').nodeValue ); objClass.setValue2 ( nodes[ctr].getAttributeNode('value2').nodeValue ); arrObjectList[ objClass.geName() ] = objClass;} /* end for loop */return arrObjectList;} /* end Process Object List */Class Codefunction clsNewClass(){var Name = '';var Value1 = '';var Value2 = '';this.geName = function() { return Name; }this.getValue1 = function() { return Value1; }this.getValue2 = function() { return Value2; }this.setName = function(inVal) { Name = inVal; }this.setValue1 = function(inVal) { Value1 = inVal; }this.setValue2 = function(inVal) { Value2 = inVal; }} // end class New ClassSo what do you think. I have a lot of coding that is stalled by this. I do not code for a living, and at some point I will pull out jquery or prototypejs and convert things over, but that is not what I am looking for right now. I tried this by declaring the may associative array in the following ways, none of which worked: new Array(), new Object(), and Object();Thanks guys.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.