I added checkboxes to an HTML table, and I would like to know if have any checkboxes checked. I have a script that works in Jquery that tells me the amount of checkboxes marked in a variable, but I haven't found how to use a Jquery variable in a Jinja if statement condition, or if there's any other way.
So what I would like to get is:
if any checkbox is checked or if Jquery var > 0 (I don't know which way is possible)
{% if current_user.is_authenticated %}
{% if var > 0 %}
<form method="POST">
<div class="form-group">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
{% else %}
<div class="form-group">
<button type="submit" class="btn btn-primary" onclick="submiton()">Submit</button>
</div>
{% endif %}
{% else %}
<div class="form-group">
<button type="submit" class="btn btn-primary" onclick="submitoff()">Submit</button>
</div>
{% endif %}
JQuery function to get number of checkbox checked:
<script>
function qtd_checkbox() {
var numberOfChecked = $('input:checkbox:checked').length;
}
</script>