I have a page with a search bar that has auto complete according to the data in a separate js file. If I type in a letter it throws out the related names that starts with or contains that letter, if I select the result if displays the details that come with that name. I just need to know how to link an an image to that data so when selected a picture is displayed with that info of the name.
Here is my Javascript code:
$(function(){
var currencies = [
{ value: 'Murray Smith', data: 'AFN', foto: src='img/logo.jpg' },
{ value: 'Brown Church', data: 'ALL' ,foto: src='../img/logo.jpg'},
{ value: 'Jack Jones', data: 'DZD' ,foto: src='../img/logo.jpg'},
{ value: 'Ben Clark', data: 'EUR' ,foto: src='../img/logo.jpg'},
{ value: 'Pete White', data: 'AOA' ,foto: src='../img/logo.jpg'},
{ value: 'East Caribbean dollar', data: 'XCD' ,foto: src='../img/logo.jpg'},
];
// setup autocomplete function pulling from currencies[] array
$('#autocomplete').autocomplete({
lookup: currencies,
onSelect: function (suggestion) {
var thehtml = '<strong>Currency Name:</strong> ' + suggestion.value + ' <br> <strong>Symbol: </strong> ' + suggestion.data + '<br> <strong>Profile Pic:</strong> ' + suggestion.foto;
$('#outputcontent').html(thehtml);
}
});
});
Thank you in advance.
src: '../image/logo.jpg'? I am sure that would work :)foto: src='img/logo.jpg'contains syntax errors.