<script type="text/javascript">
$(function() {
$("#send_to").autocomplete({
source: function(request, response) {
$.ajax({
url: "find_ships.php",
dataType: "json",
data: {
//featureClass: "P",
//style: "full",
//maxRows: 10,
term: request.term
},
success: function(data) {
var re=new RegExp('^('+request.term+')(.*)','i');
response($.map(data.users, function(item) {
return {
label: item.first_name.replace( re, "<strong class='hit'>$1</strong>$2") + " " + item.last_name.replace( re, "<strong class='hit'>$1</strong>$2"),
value: item.first_name + " " + item.last_name,
company: item.co_name
}
}))
}
})
},
minLength: 1,
focus: function(event, ui) {
$('#send_to').val(ui.item.label.replace(/[<][^>]+>/g,''));
return false;
},
select: function(event, ui) {
$('#send_to').val(ui.item.label.replace(/[<][^>]+>/g,''));
//$('#project-id').val(ui.item.value);
//$('#project-description').html(ui.item.desc);
//$('#project-icon').attr('src', '../images/' + ui.item.icon);
return false;
}
})
.data( "autocomplete" )._renderItem = function( ul, item ) {
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a class='hit' style='float: left;'><div><div class='poster_img'></div><span class='para'><strong>" + item.label + "</strong><br>" + item.company + "</span></div></a>" )
.appendTo( ul );
};
});
</script>
|