Checklist (with checkbox) javacode help

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
});

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

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>');