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

331
Views
Is there a way to disable a button in Flask?

I'm new in Flask and I would to disable a button depending on condition. In particular, I have a page with 5 selectboxe and I would like to enable the button if a value is selected for one of them.

This is my HTML code:

<form class="form-text" method="POST">

    <link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='styles/sections.css') }}">
    <script src="{{url_for('static', filename='js/sections.js')}}"></script>

    <div class="row">
        <div class="col-md-6">
            <div class="row">
                <div class="col-12">
                    <label>Section 1:</label>
                    <select onselect="validate()" id="section-one" name="select_section" style="width:200px; margin-left: 30px;">
                        <option value="select-option"> &#45;&#45; select an option &#45;&#45; </option>
                        {% for each in dropdown_list %}
                        <option value="{{each}}">{{each}}</option>
                        {% endfor %}
                    </select>
                </div>
            </div>
            <div class="row">
                <div class="col-12">
                    <label>Section 2:</label>
                    <select name="select_section" style="width:200px; margin-left: 30px;">
                        <option disabled selected value> &#45;&#45; select an option &#45;&#45; </option>
                        {% for each in dropdown_list2 %}
                        <option value="{{each}}">{{each}}</option>
                        {% endfor %}
                    </select>
                </div>
            </div>
        </div>
    </div>
    <button id="select-button" type="submit" class="btn btn-primary">Select</button>
...
</form>

This is my JS code:

function validate() {
    var ddl = document.getElementById("section-one");
    var selectedValue = ddl.options[ddl.selectedIndex].value;
    var myBtn = document.getElementById("select-button");
    if (selectedValue == "select-option") {
        document.getElementById("select-button").disabled = true;
    }  else {
        document.getElementById("select-button").disabled = false;
    }
}

In my JS code I tried just for the first select. What's wrong? Thank you in advance.

about 4 years ago · Juan Pablo Isaza
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!