How to add Auto suggestion in Jquery by customer name for customer id

T o add Auto suggestion in jquery for customer name and customer id

 $('#customer_name').autocomplete({
    source : function (request, response) {
        $.getJSON("ajax_angular_view.php?action=view_customers", {
            term: request.term
        }, function(data) {                     
            var array = data.error ? [] : $.map(data.Clist, function(m) {
                return {
					
                    label: m.name,
                    value: m.value
                };
            });
            response(array);
        });
    },   select: function (event, ui) {
		  event.preventDefault();
        $("#customer_name").val(ui.item.label); // display the selected text
        $("#user_id").val(ui.item.value); // save selected id to hidden input
        return false;
          }
,    focus: function(event, ui) {
        event.preventDefault();
        $("#customer_name").val(ui.item.label);
    }
});

ajax_angular_view.php?action=view_customers Result should be

{“Clist”:[{“name”:”Hareram Sharma”,”value”:”1″},{“name”:”Jitender”,”value”:”2″},{“name”:”soni”,”value”:”3″}]}

My Thought

Your email address will not be published. Required fields are marked *

Our Tool : hike percentage calculator