<script type="text/javascript"> $(function() { function format(mail) { return mail.name + " <" + mail.to + ">"; } $("#email").autocomplete('emails.php', { multiple: true, parse: function(data) { return $.map(eval(data), function(row) { return { data: row, value: row.name, result: row.name + " <" + row.to + ">" } }); }, formatItem: function(item) { return format(item); } }).result(function(e, item) { $("#content").append("<p>selected " + format(item) + "</p>"); }); }); </script>