SrinivasAppQube
SrinivasAppQube

Reputation: 301

iterate the object id in parse.com using javascript

my class having the 3 records and 3 objects. how i iterate the multiple objects and how i get the details of those objects thank you advance.

it is working with one object id manual

 query.get("36iUEFs7YL", 
  {
    success: function(res) {      
     var objectId=res.id;
            var productName=res.get("ProductName");
            var productPrice=res.get("ProductPrice");
            var productQuantity=res.get("ProductQuantity");
            console.log("Id is:"+objectId);
            console.log("test1"+productName);
            console.log("test2"+productPrice);
            console.log("test3"+productQuantity);
         },
  error: function(object, error) 
   {
        console.log("ERROR::"+error.message);
   }
});

o/p: Id is:36iUEFs7YL
test1deal
test21233
test310

Upvotes: 0

Views: 55

Answers (1)

SrinivasAppQube
SrinivasAppQube

Reputation: 301

Finally i got it

  query.find({
 success: function(results) {

console.log(results.length);
// Do something with the returned Parse.Object values
 for(i=0;i<results.length;i++)
     {
  var object = results[i];
         productname=object.get('ProductName');
         productPrice=object.get('ProductPrice');
         productQuantity=object.get('ProductQuantity');
    console.log(object.id + ' - ' + object.get('ProductName'));    
    //document.getElementById("app_name").innerHTML= productname;
    console.log(object.id + ' - ' + object.get('ProductPrice'));
    //document.getElementById("app_price").innerHTML= productPrice;
    console.log(object.id + ' - ' + object.get('ProductQuantity'));
    //document.getElementById("app_quantity").innerHTML= productQuantity;    
   }
  },
  error: function(error) {
   alert("Error: " + error.code + " " + error.message);
  }
 });

o/p:3 36iUEFs7YL - deal
36iUEFs7YL - 1233
36iUEFs7YL - 10
omU8oo7DOM - Samsung
omU8oo7DOM - 12500
omU8oo7DOM - 12
8oegUWDl6W - idea
8oegUWDl6W - 12

Upvotes: 1

Related Questions