# Checklist (with checkbox) javacode help

**URL:** <https://forums.knack.com/t/checklist-with-checkbox-javacode-help/7658>\
**Category:** Ask Developers\
**Created:** [April 22, 2016, 12:16am UTC](https://forums.knack.com/t/checklist-with-checkbox-javacode-help/7658 "2016-04-22T00:16:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guilhermeb42087](https://avatars.discourse-cdn.com/v4/letter/g/a87d85/32.png) [@Guilhermeb42087](https://forums.knack.com/u/Guilhermeb42087)\
**Post date:** [April 22, 2016, 12:16am UTC](https://forums.knack.com/t/checklist-with-checkbox-javacode-help/7658/1 "2016-04-22T00:16:19Z")

</div>

Hi guys,

I'm planning to create a checklist using javascript code to create checkbox in a table (which will be my checklist). The problem is that I do not know how to javascript program and was wondering if anyone could tell me how to make my app record when an item is checked. I also would like to know if there is a way to make checkbox go from left side to the right side.

Here is the code I used to make the checkbox appear in a table:

```
// function that adds checkboxes
var addCheckboxes = function(view) {

// add the checkbox to to the header to select/unselect all  
$(’#’ + view.key + ‘.kn-table thead tr’).prepend(’\<th\>\<input type=“checkbox”\>\</th\>’);  
$(’#’ + view.key + ‘.kn-table thead input’).change(function() {

```
$('.' + view.key + '.kn-table tbody tr input').each(function() {
  $(this).attr('checked', $('#' + view.key + '.kn-table thead input').attr('checked') != undefined);
});

```

});

// add a checkbox to each row in the table body  
$(’#’ + view.key + ‘.kn-table tbody tr’).each(function() {  
$(this).prepend(’\<td\>\<input type=“checkbox”\>\</td\>’);  
});  
}

// add checkboxes to a specific table view (view\_289). Change “view\_289” to your view key  
$(document).on(‘knack-view-render.view\_289’, function (event, view) {  
addCheckboxes(view);  
});

// Cycle through selected checkboxes. Use this in any code that needs to get the checked IDs  
$(’#view\_289 tbody input[type=checkbox]:checked’).each(function() {  
// add code here to get record id or row value  
var id = $(this).closest(‘tr’).attr(‘id’); // record id  
});
```

---

<div class="post-metadata">

**Author:** ![LucasTrihe34689](https://avatars.discourse-cdn.com/v4/letter/l/a87d85/32.png) [@LucasTrihe34689](https://forums.knack.com/u/LucasTrihe34689)\
**Post date:** [January 18, 2017, 12:32am UTC](https://forums.knack.com/t/checklist-with-checkbox-javacode-help/7658/2 "2017-01-18T00:32:52Z")

</div>

Hi all,  
did you have any luck figuring this out? I'm looking at implementing checkboxes as well, and I'm keen for as much info as possible before I start.

I've only got limited javascript knowledge as well, but I explore my way through problems most of the time.

Cheers

---

<div class="post-metadata">

**Author:** ![Crystal34501](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@Crystal34501](https://forums.knack.com/u/Crystal34501)\
**Post date:** [June 28, 2016, 7:16pm UTC](https://forums.knack.com/t/checklist-with-checkbox-javacode-help/7658/3 "2016-06-28T19:16:55Z")

</div>

While I have not been successful at getting this code to do anything with the checked ID's, I know that if you change the .prepend to .append it will move the checkboxes to the right side of your table.

// add the checkbox to to the header to select/unselect all

$('#' + view.key + '.kn-table thead tr').append('\<th\>\<input type="checkbox"\>\</th\>');

and

// add a checkbox to each row in the table body

$('#' + view.key + '.kn-table tbody tr').each(function() {

$(this).append('\<td\>\<input type="checkbox"\>\</td\>');
