I have a textbox with autocomplete functionality. My Code is,
<script>
$(function() {
var items = [ 'France', 'Italy', 'Malta', 'England',
'Australia', 'Spain', 'Scotland' ];
function split( val ) {
return val.split( /,\s*/ );
}
function extractLast( term ) {
return split( term ).pop();
}
$( "#skills" )
.autocomplete({
minLength: 0,
source: function( request, response ) {
response( $.ui.autocomplete.filter(
items, extractLast( request.term ) ) );
},
focus: function() {
return false;
},
select: function( event, ui ) {
var terms = split( this.value );
// remove the current input
terms.pop();
// add the selected item
terms.push( ui.item.value );
// add placeholder to get the comma-and-space at the end
terms.push( "" );
this.value = terms.join( ", " );
return false;
}
});
});
</script>
The above code is working fine. Now the problem is, I want to display values from database instead of var items = [ 'France', 'Italy', 'Malta', 'England', 'Australia', 'Spain', 'Scotland' ];. I want to change values inside variable item.
My codeigniter controller code is,
$data['skills'] = $this->workdone->getAllSkills();
$this->load->view($page, $data);
My HTML code is,
<input type="text" name="skills" id="skills">
I have tried a lot. Is there any solution.