Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

253
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda