steve5588065
Posts: 0
Joined: Tue Feb 26, 2013 6:36 am

loop through json array

I have an Appery database List_service which returns all the rows in the database.
In the success event I need to loop thru the rows to get a total Price (sum of cost column)

success event javascript
var m = JSON.stringify(data);
alert(m.length.toString());

The alert shows 161 when there is only 1 row in the database

if I use the following
for (var i=0, l=m.length; i}]

what am I doing wrong

regards
Steve

steve5588065
Posts: 0
Joined: Tue Feb 26, 2013 6:36 am

loop through json array

not sure what happened

half the text didn't appear in the post

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

loop through json array

Hi Steve,

We'll take a look.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

loop through json array

Hi Steve,

codevar m = JSON.stringify(data); //here you convert data to string
alert(m.length.toString()); //here you display its length/code
Please replace with the following code to see array length:
codealert( m.length );/code

Then, replace:
codefor (var i=0, l=m.length; i}]/code
With:
codefor (var i=0, i < data&#46;length; i++) {
&#47;&#47; place for your code&#46; each item will be at data
}/code

steve5588065
Posts: 0
Joined: Tue Feb 26, 2013 6:36 am

loop through json array

Hi Katya

Thank you for this information

Worked perfectly

regards
Steve

Return to “Issues”