This is my first Django project I have this simple form which I would like to submit all row values (checked or unchecked), The error I am facing is that it only sends row{num}
value if it is checked.
<script>
function calc(elemId)
{
var elem = document.getElementsByName(elemId)[0];
if (elem.checked)
{
elem.value = 1;
} else {
elem.value = 0;
}
}
</script>
<div class="container pt-3">
<form action="." method="post">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Keyword</th>
<th scope="col">seller_items</th>
<th scope="col">Total</th>
<th scope="col">checked</th>
</tr>
</thead>
{% csrf_token %}
{{ form|crispy }}
{%for i in data%}
<tr >
<th scope="row">{{forloop.counter}}</th>
<td>{{i.keyword}}</td>
<td>{{i.seller_items}}</td>
<td>{{i.total_found}}</td>
<td>
{% if i.checked %}
<input type="checkbox" name="row{{i.id}}" value="1" checked="checked" onclick="calc('row{{i.id}}')"/>
{%else%}
<input type="checkbox" name="row{{i.id}}" value="0" onclick="calc('row{{i.id}}')"/>
{%endif%}
</td>
</tr>
{% endfor %}
</table>
<div class="row">
<div class="col-12">
<button class="btn btn-primary float-right" type="submit">Update</button>
</div>
</div>
</form>
the form is submitted when the button is pushed but only checked boxes rows are in the post request