Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
Show a specific data from jinja2 according to a checkbox is checked or not

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
    
}


}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda