Javascript Push() and value access

Isaac
Isaac used Ask the Experts™
on
Hi,

Can someone check and see if the following javascript is correct?  I am trying to push values from a sharepoint list into a multidimensional array but I think I might be doing something wrong when I try to access.  I get an error due to the .each() and when I take it out, the error goes away.  The error says I'm missing a ")"

var anArray = new Array();


$().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "Analyst",
	CAMLViewFields: "<ViewFields><FieldRef Name='Title'></FieldRef></ViewFields>",
	CAMLQuery: "<Query><OrderBy><FieldRef Name='Title' /></OrderBy></Query>",
    completefunc: function (xData, Status) {
	//alert(xData.responseXML.xml);
      $(xData.responseXML).SPFilterNode("z:row").each(function() { 


			anArray.push({
				Analyst: $(this).attr("ows_Title"),
				Count:	 0
				});			
				


      });
     }
  }); 


   //Am I accessing the values to my array correctly
   $.each(anArray, function (index, value) {																													
        dataAn.addRow([anArray[index].Analyst, Number(anArray[index].Count]));
    }); 

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
I think you're missing a parenthesis...try each(function()) and see http://www.w3schools.com/Php/func_array_each.asp
IsaacSharePoint Client Side Developer

Author

Commented:
I am using jquery not php

Commented:
Then you maybe have inserted } instead of }); at line 23.
IsaacSharePoint Client Side Developer

Author

Commented:
I'm using notepad and all of my braces and parenthesis have their open and close.

Is this right?
alert(anArray[x].Count);

What's the proper syntax to get the value of that kind of an array?
Commented:
anArray[x] is the right syntax to get the x-element of the array, while anArray.length will return the number of elements in the array.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial