I have a specific select that I would change the options according to with a checkbox that is either checked or not. This select is inside another Jinja2 loop, like below:
{% for row in tbl_cli %}
...code before the specific header and checkbox ...
<th width=29% style="background-color: #DBCEA7;color:black;z-index: 100;">Destino<br><label sytle="display: inline-block;"><input type="checkbox" onClick="libera(this)" id="libera_check" /> Habilitar todas as agências </label> </th>
<tr>
... a lot of code ...
<td>
<select class="form-select" style="font-size: 10px; width: 90%" name="ger_escolhido" id="{{ row['ID_ROW_GRTE'] }}">
<option value="" disabled selected>Selecione o gerente destino</option>
{% if variable_to_check == 0 %}
{% for ger in tbl_codger %}
<option style="font-size: 10px;" name="{{ ger['CHAVE'] }}">{{ ger['CHAVE'] }}</option>
{% endfor %}
{% else %}
{% for ger_ag_de in tbl_codger_AG_DE %}
<option style="font-size: 10px;" name="{{ ger_ag_de['CHAVE'] }}">{{ ger_ag_de['CHAVE'] }}</option>
{% endfor %}
{% endif %}
</select>
</td>
... another chunck of code ...
</tr>
{% endfor %}
So far, I've created a variable called variable_to_check in the javascript, but the jinja2 does not seem to get the value of this variable:
variable_to_check == 0
function libera() {
let check = document.getElementById('libera_check')
if (check.checked) {
var_libera_todas_agencias = 1
} else {
var_libera_todas_agencias = 0
}
}