Tengo una selección específica en la que cambiaría las opciones de acuerdo con una casilla de verificación que está marcada o no. Esta selección está dentro de otro bucle Jinja2, como a continuación:
{% 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 %}Hasta ahora, he creado una variable llamada variable_to_check en javascript, pero jinja2 no parece obtener el valor de esta 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 } }