# How to prefield multiple checkbox based on databse value

**URL:** <https://forum.ionicframework.com/t/how-to-prefield-multiple-checkbox-based-on-databse-value/193851>\
**Category:** ionic-v3\
**Created:** [August 4, 2020, 4:20am UTC](https://forum.ionicframework.com/t/how-to-prefield-multiple-checkbox-based-on-databse-value/193851 "2020-08-04T04:20:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![flycoders\_sourav](https://avatars.discourse-cdn.com/v4/letter/f/e47c2d/32.png) [@flycoders\_sourav](https://forum.ionicframework.com/u/flycoders_sourav)\
**Post date:** [August 4, 2020, 4:20am UTC](https://forum.ionicframework.com/t/how-to-prefield-multiple-checkbox-based-on-databse-value/193851/1 "2020-08-04T04:20:04Z")

</div>

I have one array that contain all the office list. another array is user selected list. so now I want to display all officelist and if the value in selected list is the same with office list then the checkbox will be checked

```auto
this.officeLIST = [
  { "office_id": "1", "officename": "Sun Dept" },
  { "office_id": "2", "officename": "Moon" },
  { "office_id": "3", "officename": "Stars" }
]

```

Selected list array

```auto
"office": [
    {
      "office_id": "1",
      "officename": "Sun Dept"
    },
    {
      "office_id": "2",
      "officename": "Moon Dept"
    }
  ]

```

Thank you.

---

<div class="post-metadata">

**Author:** ![PratikVaity](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@PratikVaity](https://forum.ionicframework.com/u/PratikVaity)\
**Post date:** [August 4, 2020, 5:48am UTC](https://forum.ionicframework.com/t/how-to-prefield-multiple-checkbox-based-on-databse-value/193851/2 "2020-08-04T05:48:39Z")

</div>

> [@flycoders\_sourav](#):
>
> user selected list

You will ngfor the first array to display the data right?

---

<div class="post-metadata">

**Author:** ![flycoders\_sourav](https://avatars.discourse-cdn.com/v4/letter/f/e47c2d/32.png) [@flycoders\_sourav](https://forum.ionicframework.com/u/flycoders_sourav)\
**Post date:** [August 4, 2020, 6:37am UTC](https://forum.ionicframework.com/t/how-to-prefield-multiple-checkbox-based-on-databse-value/193851/3 "2020-08-04T06:37:22Z")

</div>

No. actually i create a new array like array like this

```auto
filter_array(){

    for (var i = 0; i < this.getSize.length; i++) {

      var ismatch = false; // we haven't found it yet

      for (var j = 0; j < this.pro_size_list.length; j++) {

        if (this.[i].size_id == this.pro_size_list[j].product_size) {

          ismatch = true;

          this.getSize[i].checked = true;// checkbox status true

          this.newArray.push(this.getSize[i]);

          break;

        }//End if

      }

  

      if (!ismatch) {

        this.getSize[i].checked = false;// checkbox status false

        this.newArray.push(this.getSize[i]);

      } //End if

    }

    console.log(this.newArray);

  }

```

---

<div class="post-metadata">

**Author:** ![flycoders\_sourav](https://avatars.discourse-cdn.com/v4/letter/f/e47c2d/32.png) [@flycoders\_sourav](https://forum.ionicframework.com/u/flycoders_sourav)\
**Post date:** [August 4, 2020, 6:42am UTC](https://forum.ionicframework.com/t/how-to-prefield-multiple-checkbox-based-on-databse-value/193851/4 "2020-08-04T06:42:54Z")

</div>

This is my html

```auto
<div class="form-group">

          <ion-label for="brname" class="wizard-form-text-label" position="stacked" >Select Size*</ion-label>

          <ion-select interface="popover" multiple="true" cancelText="Nah" okText="Okay!" class="form-control">

            <ion-select-option *ngFor="let item of newArray" checked="true" value="{{item.size_id}}">{{item.size}}</ion-select-option>

          </ion-select>

        </div>

```

Please can you tell me there have any **checked** properties of ion-select?
