I've seen other questions similar to this one, but I don't know if my application isn't working because I'm using a Flask/SQLAlchemy application (a truck scheduling application) or if there's something else I'm missing. I want to disable the submit/update button until the user selects one of the materials to be picked up.
update.html:
<h3>Update Appointment:</h3><br>
<form action="/update/{{appt.id}}" method="POST">
<label>Carrier:</label>
<input type="text" name="carrier" id="carrier"
value="{{ appt.carrier }}"><br>
<h4>Current material = {{ appt.material }}</h4>
<label>Select a new material:</label><br>
<input type="radio" name="material_update" id="HCl" value="HCl">
<label for="HCl">HCl</label><br>
<input type="radio" name="material_update" id="Caustic" value="Caustic">
<label for="Caustic">Caustic</label><br>
<input type="radio" name="material_update" id="Bleach" value="Bleach">
<label for="Bleach">Bleach</label><br>
<button type="submit" id="update_button" disabled>Update Appointment</button>
</form>
<script>
document.getElementsByName('material_update')
.addEventListener('click', enable);
function enable() {
document.querySelector('#update_button').disabled = False;
}
</script>