Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.4K
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!