# How to Add Checkboxes to Your Table and Add Logic to Them!

> The following is a solution for adding checkboxes with logic to your table. As well as a solution to know which record gets selected.

Source: https://tadabase.com/docs/snippets/how-to-add-checkboxes-to-your-table-and-add-logic-to-them  
Status: Not yet re-checked. Moved from our previous help site and not yet re-checked against the current product. Last edited Sep 20, 2024.

![Screenshot for “How to Add Checkboxes to Your Table and Add Logic to Them!”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/2022-09-21_22-44-01.png)

The following is a solution for adding checkboxes with logic to your table. As well as a solution to know which record gets selected.

**Step 1**

**Add an action link to your table.**

![Screenshot for “How to Add Checkboxes to Your Table and Add Logic to Them!”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/2022-09-21_16-26-30.png)

**Step 2**

**Add a CSS class of "check" to your action link.**

![Screenshot for “How to Add Checkboxes to Your Table and Add Logic to Them!”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/2022-09-21_16-28-37.png)

**Step 3**

**In the JavaScript tab of your page, add the following code.**

```
TB.render('component_3', function(data) {
    var elems = document.getElementsByClassName("check");

    for (let i = 1; i < elems.length; i++) {
        elems[i].innerHTML = "<input type='checkbox'>";
    }
});
```

![Screenshot for “How to Add Checkboxes to Your Table and Add Logic to Them!”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/2022-09-21_16-31-34.png)

> **Note:** Remember to change the component ID within the code above to match the component ID of your table containing the action link.

![Screenshot for “How to Add Checkboxes to Your Table and Add Logic to Them!”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/2022-09-21_16-33-21.png)

**In case you want to know which record gets selected, you can add this to code a custom component:**

```html
var checkboxes = document.getElementsByClassName("check");
 for (let i = 0; i < checkboxes.length; i++) {
        if(checkboxes[i].checked){
          // Do your logic
          //If you want to get ID of each record you should pass it in the checkbox innerHTML
        }     
}
```

**Original Community Post:**

[How to add checkboxes to your table and add logic to them! - Community Discussions / Tips and Tricks - Tadabase Community](https://community.tadabase.io/t/how-to-add-checkboxes-to-your-table-and-add-logic-to-them/1541)
