# Trouble getting checkboxes to appear with javascript

**URL:** <https://forums.knack.com/t/trouble-getting-checkboxes-to-appear-with-javascript/11826>\
**Category:** Get Answers\
**Created:** [January 4, 2022, 12:03pm UTC](https://forums.knack.com/t/trouble-getting-checkboxes-to-appear-with-javascript/11826 "2022-01-04T12:03:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Terence](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@Terence](https://forums.knack.com/u/Terence)\
**Post date:** [January 4, 2022, 12:03pm UTC](https://forums.knack.com/t/trouble-getting-checkboxes-to-appear-with-javascript/11826/1 "2022-01-04T12:03:12Z")

</div>

Hi, I am trying to add checkboxes to one of my views using the javascript example depicted here: [https://docs.knack.com/docs/javascript-jquery-examples#add-checkboxes-to-a-table](https://docs.knack.com/docs/javascript-jquery-examples#add-checkboxes-to-a-table)

but for some reason, they never seem to appear?

My view is view 115, here is the code:

// 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\_1). Replace view\_1 with your view key

$(document).on(“knack-view-render.view\_115”, function (event, view) {

addCheckboxes(view);

});

// Cycle through selected checkboxes. Use this in any code that needs to get the checked IDs

$("#view\_115 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

});

Not sure if there is more of this example that needs changing

Thanks for any potential help

---

<div class="post-metadata">

**Author:** ![ChrisPetty](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/chrispetty/32/1216_2.png) [@ChrisPetty](https://forums.knack.com/u/ChrisPetty)\
**Post date:** [January 6, 2022, 1:52am UTC](https://forums.knack.com/t/trouble-getting-checkboxes-to-appear-with-javascript/11826/2 "2022-01-06T01:52:46Z")

</div>

Hey. Are you getting any Javascript errors in the console for the page that has that view in it? Is your ‘view\_115’ a table with data in it?

Chris.
