php - how to use select method with auto complete? -


code:

<script> $(function() {     $( "#college_name" ).autocomplete({         source: 'search.php',         minlength:2,         select: function(event, ui) {     var x = ui.item.value;     $("#college_name").attr('value',x);     }     }); }); </script>  <script>    $(document).ready(function(){        $("#college_name").select(function(){           alert("hi");        });    }); </script> 

html code:

<input type="text" id = "college_name"  name = "college_name" value="" placeholder = "college name" autocomplete="off"> <input type='text' name='college_id' id='college_id'> 

in code when wrote college name in college_name input field autocomplete search i.e. search.php working college showing. when select college autocomplete not show message (hi) or thing. so, how can fix problem.

thank you

add alert message in select event of autocomplete.

 <script>     $(function() {         $( "#college_name" ).autocomplete({             source: 'search.php',             minlength:2,             select: function(event, ui) {         var x = ui.item.value;         $("#college_name").attr('value',x);          alert("hi");         }         });     });     </script> 

Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -