javascript - jquery autocomplete with hidden data cant get id and value -


i using jquery.autocomplete.js. can term , output sent using json encode, can't value in 1 textbox , id in hidden textbox.

  1. script:

    <script type="text/javascript"> $().ready(function() { $(".autocomplete_user").autocomplete("/get_user_name", {     minchars: 0,     max: 12,     autofill: true,     mustmatch: true,     matchcontains: false,     scrollheight: 220,     formatitem: function(row, i, total) {         return row.value;     },     formatresult: function(row) {         return row.value;     } }); $('.autocomplete_user').result(function(event, data, formatted) {     $('#user_id_val').val(!data ? '' : data.id); }); 

    });

  1. view:
<input type="text" class="form-control input-md autocomplete_user" name="receiver_name" value="" placeholder=" type here"> <input type="hidden" name="receiver_id" id="user_id_val" value="" /> 
  1. i can output this

    [{id: "131", value: "murugan"}]


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -