I have a problem with a smart search list that I need to send the form once the value is selected. However, it does not work until I click outside the field.
The code is as follows:
<input id="ComunaBuscador" name="city" class="form-control" placeholder="Escribe la comuna" list="cities" autocomplete="off" required onchange='this.form.submit()' >
<datalist id="cities">
<?php go_citylist();?>
</datalist>
The go_citylist
function generates the following as you type:
<datalist id="cities">
<option value="Arica">
<option value="Cañete">
<option value="Hualañé">
<option value="Independencia">
<option value="Papudo">
<option value="Temuco">
</datalist>
The problem is that when I finish writing, I select some of the options that meet the search criteria and the event onchange
is not activated until I click outside the input
(and this does not happen because it is the only one field and there is no submit
button).
Is there a javascript event to help me with this? Any other way to send the form?