-2

I have var customer array and I stored my response in that array. Now I need to populate the values to table, if intrstd present in response.

I am unable to get that .

JSON:

var customer = 
 [
  [
    {
      "businessuserid": 52,
      "businessusername": "Cars workshop",
      "businessusermobile": "9535000636",
      "businessusercountrycode": "91",
      "admin": true,
      "mobilevalidated": true,
      "emailvalidated": false,
      "email": "preethi@car.com",
      "upin": "000052"
    },
    {
      "businessuserid": 59,
      "businessusername": "MCF Business",
      "businessusermobile": "00",
      "businessusercountrycode": "91",
      "admin": true,
      "mobilevalidated": true,
      "emailvalidated": false,
      "email": "pavanhachholli@groupz.in",
      "upin": "000059"
    }
  ],
  [
    {
      "businessuserid": 44,
      "businessusername": "rk business New",
      "businessusermobile": "00",
      "businessusercountrycode": "91",
      "admin": true,
      "mobilevalidated": false,
      "emailvalidated": false,
      "email": "riteshnew@gmail.com",
      "upin": "000044"
    }
  ],
  [
    {
      "approved": true,
      "businessuserid": 43,
      "businessusername": "Cakey Bakes",
      "businessusermobile": "8050663763",
      "businessusercountrycode": "91",
      "admin": true,
      "mobilevalidated": true,
      "emailvalidated": false,
      "email": "preethi@groupz.com",
      "upin": "000043"
    }
  ],
  [
    {
      "intrsted": true,
      "attended": false,
      "businessuserid": 44,
      "businessusername": "rk business New",
      "businessusermobile": "00",
      "businessusercountrycode": "91",
      "admin": true,
      "mobilevalidated": false,
      "emailvalidated": false,
      "email": "riteshnew@gmail.com",
      "upin": "000044"
    }
  ],
  [
    {
      "intrsted": true,
      "attended": false,
      "businessuserid": 52,
      "businessusername": "Cars workshop",
      "businessusermobile": "9535000636",
      "businessusercountrycode": "91",
      "admin": true,
      "mobilevalidated": true,
      "emailvalidated": false,
      "email": "preethi@car.com",
      "upin": "000052"
    }
  ]

JS:

   $scope.userdetails = function(){
    for(var i=0;i<$scope.newuserlist[i].length;i++){


        for(var j=0;j<$scope.interested.length;j++){

               if($scope.interested[j].intrsted == undefined){
                        $scope.undefinedprogram = "null";
                    }
                    else if($scope.interested[j].intrsted == true){
                         $scope.users = $scope.interested[j].businessusername; 
            console.log($scope.users );
                        $scope.modalvalues.push($scope.users);
            console.log($scope.modalvalues);
                    }
        }
        }

};

If I am able to fetch only array values where "intrsted": tag is present,I will be able to populate the value in table accordingly.

Nicoleta Wilskon
  • 687
  • 1
  • 10
  • 32

2 Answers2

1

Assuming angularjs since you have the angularjs tag. You could use ng-repeat to loop through your data, and use a filter to display only the relevant records:

<table>
    <tr ng-repeat="item in your.controller.your.data | filter: { intrsted: true }">
        <td>{{item.businessusername}}</td>
        ...
    </tr>
</table>

But really, this is the most basic angularjs application possible. You can get this information from any beginner tutorial.

Kev
  • 2,656
  • 3
  • 39
  • 63
0

try this may help you

var tbl=$("<table/>").attr("id","mytable");
    $("#div1").append(tbl);
    for(var i=0;i<customer.length;i++)
      {
         var tr="<tr>";
         var td1="<td>"+customer[i]["id"]+"</td>";
         var td2="<td>"+customer[i]["businessusername"]+"</td>";
         var td3="<td>"+customer[i]["businessusermobile"]+"</td></tr>";
         $("#mytable").append(tr+td1+td2+td3); 

    }