I have multidimensional array that include department and category.
Based on the selecting department and category, i need to search names.
below is my code
$shop = array( array( "emp_name" => "ramu",
"department_name" => "cse",
"Number" => 15
),
array( "emp_name" => "ramesh",
"department_name" => "eee",
"Number" => "56",
),
array( "emp_name" => "ravi",
"department_name" => "it",
"Number" => 7
)
);
and my jquery and auto complete code is
var resources = <?php echo json_encode($shop, JSON_FORCE_OBJECT);?>;
jq( ".project" ).autocomplete({
minLength: 1,
source: resources,
focus: function( event, ui ) {
jq(this).val( ui.item.label );
return false;
},
select: function( event, ui ) {
jq(this).val( ui.item.label );
return false;
}
});
jq('.project').each(function(i, el) {
jq(el).data('ui-autocomplete')._renderItem = function(ul, item) {
return jq( "<li>" )
.append( "<div class='emp-name'><a style='font-size:18px'>" + item.resources['emp_name'] + "</a><a style='font-size:13px'>" + item.resources['department_name'] + "</a></div><div id='clear'/>" )
.appendTo( ul );
};
});
my html code like this
<select name="dept" id="dept">
--
</select>
<select name="dept" id="dept">
--
</select>
<input type="text" name="project" class="project" id="project">
after selecting dept and cate i need to display autocomplete particular emp_name
any body help me...