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

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -