saifuddinazhar
4/13/2018 - 12:19 AM

UI - Checkbox

checkbox, get selected, loop selected,

 <div class="row" id="checkboxCentres">
    @foreach (Centre centre in ViewBag.DestinationCentres)
    {
        <div class="col-sm-3" style="margin-bottom:10px">
            <label class="checkbox-inline" style="margin-right:10px">
                <input type="checkbox" value="@centre.ID"> <label style="margin-left:5px">@centre.Name</label>
            </label>
        </div>
    }
</div>
 $('#checkboxCentres').find("input:checked").each(function (index, ob) {
      destinationCentreIds.push(ob.getAttribute('value'));
  });
  
  .prop('checked', true);