In my Flask app, I have a page with 5 selectbox:
<select onchange="disableBtn()" id="first" name="select_first">
<option value="option1">Select an option</option>
{% for each in list %}
<option value="{{each}}">{{each}}</option>
{% endfor %}
</select>
I would like to enable/disable the button if only one of the selectbox has an option selected.
function disableBtn() {
var select = document.getElementById("first");
var selectedValue = select.options[select.selectedIndex].value;
if (selectedValue == "option1") {
document.getElementById("button").disabled = true;
} else {
document.getElementById("button").disabled = false;
}
}
How could I use the same function for all the boxes? I tried with multiple if but it works only for the first.