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

251
Visualizações
Reference a django variable between multiple template tags in html

edited for clarity:

So I have a list of drinks in my selection drop down. Based on what is selected, I want the webpage to render the ingredients that drink has (which I get can get from my tag function drink_joins).

The first problem is the value for the dropdown is set at the first value, even if the user selects a different one.

<select>
{% for drink in drinks %}
<option id="dropdown" value="{{drink.drink_name}}">{{drink.drink_name}}</option>
{% endfor %}
</select>

I.E. here function myFunc(){x = document.getElementById('dropdown').value} will only get the first element in drinks, no matter what is selected in the dropdown.

The second problem is once that is fixed, how can I pass on that value into my tag, without it being in the for loop? For example, {{'Margarita'|drink_joins}} would return the right list but I don't know how to put a variable there instead.

<select>
{% for drink in drinks %}
<option id="dropdown" value="{{drink.drink_name}}">{{drink.drink_name}}</option>
{% endfor %}
</select> 
<p> {{ [needs string of dropdown value] | drink_joins }}</p>

problem

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