How to add checkboxes to multiple views?

I successfully added checkboxes using the code found on this forum. But now I need to add checkboxes on a different table on a different view, and I can’t figure out how to get it to work. Snippets below. Can anyone see what I’m doing wrong? I “//” a lot out due to it not working, but left the code there that I was trying. “Buckley” is the other View i’m trying to add this code to. thanks!!
JD

// Function that adds checkboxes. JD NOTE: This snippet is proviced by Knack themselves.

var addCheckboxes = function(view) {

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

$(’#’ + view.key + ‘.kn-table thead tr’).prepend(’’);

$(’#’ + 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(’’);

});

}

// Add checkboxes to a specific table view (view_1). Replace view_1 with your view key

$(document).on(‘knack-view-render.view_964’, function (event, view) {

addCheckboxes(view);

});

//buckleys

//$(document).on(‘knack-view-render.view_948’, function (event, view) {

// addCheckboxes(view);

//});

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

$(’#view_5 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

});

//buckleys - do i need to do this below??

//$(’#view_948 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

//});

var addCheckboxes = function(view) {

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

$(’#’ + view.key + ‘.kn-table thead tr’).prepend(’’);

$(’#’ + 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(’’);

});

}

// JD NOTE: THIS CODE IS FOUND ON THE KNACK USER SUPPORT FORUM

/**** CHANGE VIEW_ID TO YOUR OWN VIEW ID ****/

$(document).on(‘knack-view-render.view_964’, function(event, view) {

// Add an update button

$(’<button id=“update”">Update’).insertAfter(’.view-header’);

//buckley 2 lines below

//$(document).on(‘knack-view-render.view_948’, function(event, view) {

// Add an update button

//$(’<button id=“updateRepStatus”">Update Rep Status’).insertAfter(’.view-header’);

// Add checkboxes to our table. jd clearing bc they’re already added

//addCheckboxes(view);

// Click event for the update button

$(’#update’).click(function() {

// We need an array of record IDs

var record_ids = ;

// Populate the record IDs using all checked rows

$(’#’ + view.key + ’ tbody input[type=checkbox]:checked’).each(function() {

record_ids.push($(this).closest(‘tr’).attr(‘id’)); // record id

});

//BUCKLEY below-

// Click event for the update button

//$(’#update2’).click(function() {

// We need an array of record IDs

//var record_ids = ;

// Populate the record IDs using all checked rows

//$(’#’ + view.key + ’ tbody input[type=checkbox]:checked’).each(function() {

//record_ids.push($(this).closest(‘tr’).attr(‘id’)); // record id

//});

Knack.showSpinner();

// Define the fields you want to update

var data = {

field_918: ‘Yes’,

};

// seet the delay to prevent hitting API rate limit (milliseconds)

var myDelay = 100;

//call updateRecords function

$(function() {

updateRecords(record_ids.shift(), record_ids, data);

});

var selectedRecords = record_ids.length + 1

function updateRecords(id, records, data) {

$.ajax({

//CHANGE OBJECT_ID TO YOUR OWN OBJECT ID

url: ‘https://usgc-api.knack.com/v1/objects/object_35/records/’ + id,

type: ‘PUT’,

/***** CHANGE TO YOUR OWN APPID AND API KEY HERE *****/

headers: {

‘X-Knack-Application-ID’: ‘5dca0c4ae7XXXXXXXXX’,

‘X-Knack-REST-API-Key’: ‘0b993c50-04f2-XXXXXXXXXXXXX’

},

data: data,

success: function(response) {

if (record_ids.length > 0) {

// Every time a call is made, the array is shifted by 1.

// If the array still has a length, re-run updateRecords()

setTimeout(updateRecords(record_ids.shift(), record_ids, data), myDelay);

} else {

alert(selectedRecords + " Updated");

Knack.hideSpinner();

location.reload();

}

}

})

}

})

});

Solved it with the help of another user. Just had to shuffle the code around some and it works great now.