javascript - AutoComplete text box with text value and id -


i want auto complete text box text , id .i used following code auto complete in application

<script type="text/javascript"> var $auto=$.noconflict(); $auto(document).ready(function(){         var data3 = ['niju','vivek','anil','anil'];     $auto("#employee").autocomplete(data3);    }); </script>  <input   type="text" name="employee" id="employee" value="" class="inp-form">  

in code faced 1 drawback .there can duplicate entry possible since same values been repeated .

how id value instead of text label ?

any suggestions highly appreciated.

demo here

you can try source define : [ { label: "choice1", value: "value1" }, ... ].
see documentation here : autocomplete#option-source

in case :
var data3 = [{label: 'niju', value: 1},{label : 'vivek', value : 2}, ...]; $auto("#employee").autocomplete({source: data3});


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -