Link to home
Start Free TrialLog in
Avatar of Isaac
IsaacFlag for United States of America

asked on

Javascript Push() and value access

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

Avatar of Sar1973
Sar1973
Flag of Italy image

I think you're missing a parenthesis...try each(function()) and see http://www.w3schools.com/Php/func_array_each.asp
Avatar of Isaac

ASKER

I am using jquery not php
Then you maybe have inserted } instead of }); at line 23.
Avatar of Isaac

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of Sar1973
Sar1973
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial