There are all areas:
<input list="region" class="form-control" name="region"> <datalist id="region" > <?php foreach ($regions as $region){ ?> <option value="<?php echo $region['name']?>" selected="selected"><?php echo $region['name']?></option> <?php } ?> </datalist> They can be selected both from the drop-down list and through the search bar. Is it possible to make the data sent when choosing from the list? That is, clicked - dropped the list, chose a region, and the name of the region went to the server:
$(document).ready(function() { $('.form-control').change(function() { var regionid = $("input[name='region']").val(); console.log(regionid); $.ajax({ type: 'POST', url: '/index.php?route=checkout/checkout/region', data:{ "region_id":regionid}, beforeSend: function() { $("#loader").css("display", "block"); $("#loader").animate({ opacity: 1 }, 500); }, success: function(data) { $('#div_city').html(data); } }).done(function(data) { $("#loader").animate({ opacity: 0 }, 500, function() { $("#loader").css("display", "none"); }); }); }); }); So go after the input closes. Chose, clicked on another input or on another place, and only then the data is sent. click fails - incorrect data is sent.



<option>-a) example of the final (displayed in the browser) HTML code. - Regent<input>manually? Simply, there is a simple option in which when you select an item, the request will leave immediately, however, in this case, and when typing each character, the request will leave. Do you like this option? - Regent