I'm a newby at web development and I have tried to build a web app with flask and python.
I need to get notified when something from the select field has been chosen.
I tried to throw an
alert("test")
and the popup is shown.My second try was to set
onchange="this.form.submit()"
My third try was to set
onchange="document.getElementById('model_form').submit()"
But nothing happened, the form wasn't submitted.
I see in the browser console these exceptions:
Uncaught TypeError: document.getElementById(...).submit is not a function at
HTMLSelectElement.onchange
Uncaught TypeError: this.form.submit is not a function at
HTMLSelectElement.onchange
This is by flask rendered html code:
<form id="model_form" action="" method="post" enctype="multipart/form-data">
<div class="table-responsive">
<table class="table table-bordered">
...
<td>
<select id="myField" name="myField" onchange="this.form.submit()"><option value="b">b</option><option value="a">a</option></select>
<span class="help-block"></span>
</td>
...
<div class="well well-sm">
<button type="submit" class="btn btn-sm btn-primary">Save
<i class="fa fa-save"></i></button>
</div>
</form>
Save button works pretty fine and submits the form. How can I get notified when something from the select field is chosen?