This code snippet adds a checkbox next to each item in a list. When the checked status is changed, it will add or remove that value from the SelectedItems array:
<script type="text/x-jquery-tmpl" id="tmpl">
<input name="cSelect"
type="checkbox"
value="${ ID }"
data-bind="checked: VM.SelectedItems" />
<!-- Add other item content here -->
</script>
VM.SelectedItems = ko.observeableArray([]);
SelectedItems will always contain the ids of the items that are checked.
If you want the checkbox to add or remove an object from SelectedItems instead... For instance, if you want to store an object like { id : 3, checked : true }
rather than serializing it for the value attribute, you can modify the code accordingly.