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

1.4K
Vistas
Create CheckBox in Python Flask - Jinja Template

I have the below List in Python.

list_val = ['APPROVED','UN-APPROVED','DEACTIVATE']

and need to pass this list values into a Check box with Jinja Template.

Can someone help on this with HTML code embedded with Jinja template ?

Expected Output:-

enter image description here

HTML Need to converted with JINJA Template.

<input type="checkbox" id="val1" name="val1" value="app">
<label for="val1"> APPROVED</label><br>
<input type="checkbox" id="val2" name="val2" value="unapp">
<label for="val2"> UN-APPROVED</label><br>
<input type="checkbox" id="val3" name="val3" value="deac">
<label for="val3"> DEACTIVATE</label>

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Try this code

This code will have input tags with values like approved, un-approved, deacitvate instead of app, unapp, deac. Is that okay for you?

And also its better to put the input tag inside the label tag, because when you click the word beside the checkbox, it'll toggle the checkbox (and thats why labels are mostly used for)

As W3schools says:

Proper use of labels with the elements above will benefit:

  • Screen reader users (will read out loud the label, when the user is focused on the element)
  • Users who have difficulty clicking on very small regions (such as checkboxes) - because when a user clicks the text within the <label> element, it toggles the input (this increases the hit area).
  • Tip: The for attribute of <label> must be equal to the id attribute of the related element to bind them together. A label can also be bound to an element by placing the element inside the <label> element.
{% for i in range(list_val_len) %}
    <label for="val{{ i+1 }}" name="val{{ i+1 }}">
        <input type="checkbox" id="val{{ i+1 }}" name="val{{ i+1 }}" value="{{ list_val[i].lower() }}">
        {{ list_val[i] }}
    </label><br>
{% endfor %}

And also pass the list_val list and its length in seperate keyword arguments on the render_template function like

list_val = ['APPROVED','UN-APPROVED','DEACTIVATE']

@app.route('whatever_route_in_here')
def whatever_name_your_function_has():
    ...
    ...
    render_template('html_file_name.html', list_val=list_val, list_val_len=len(list_val))

Tell me if its not working...

over 4 years ago · Santiago Trujillo Denunciar
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