So I have a page with the following: (1) Text field = Title, (2) Dropdown (3) Text Field = Description. Also on that page I have a table that is filled with the info on a PostgreSQL table and the query is done in a .py with Flask and SQLAlchemy. Every line of the table has a slider that the user can click. When the user click on the submit button all the info that was filled need to go to the corresponding tables in the DB and if there is any sliders with status == checked that info needs to go to the table of the DB as well. I was getting the text fields and dropdown using cookies and I did try to verify if the status of the sliders are checked but so far didn't work.
Any tips about how to do this work? Is there a better way to do this besides using cookies? Thanks in advance c; I'm using HTML, Bootstrap5, Javascript, Flask, SQLAlchemy and Jinja2
HTML
{% for e in inves %}
<tr>
<td>{{ e[0] }}</td>
<td>{{ e[1] }}</td>
<td>
<label class="switch">
<input type="checkbox" id = "checkbox_inves_{{loop.index}}">
<span class="slider round"></span>
</label>
</td>
</tr>
{% endfor %}
const switchs = document.querySelectorAll(".switch");
switchs.forEach(s => {
s.querySelector("slider round").addEventListener("click", e => {
if (e.checked){
console.log("checked:" + e.target.id)
}else{
console.log("unchecked:" + e.target.id)
}
});
});