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

236
Vistas
Jinja2 + JS - How can I retrieve value from a select box using Java script + Jinja2 variable

I have a drop list with its values being populated using Jinja2. I want to fetch the value of the option selected i.e, value="{{car.key.name}}" and print it in the <p> tag below. I tried using javascript, but somehow it is not working on change of options selected.

Html+Jinja side:

<select onchange="val()" id="loop1">
            <option>------</option>
            {% for car in cars %}
            <option value="{{car.key.name}}" name="ev1_key">{{ car.ev_name }}</option>
            {% endfor %}

        </select>
        <p id="car1_key">car1_key</p>

Javascript side:

var selectTag = document.getElementById('loop1')
var pTag = document.getElementById('car1_val')
pTag.innerText = selectTag.value

function val() {
    pTag.innerText = selectTag.value;
    var strTxt = selectTag.options[selectTag.selectedIndex].value;
    pTag.innerHTML = strTxt;
}

Can anyone help me out where did I go wrong?

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